[Git][reproducible-builds/reproducible-website][master] Add a very simple Selenium-based functional testsuite.

Chris Lamb gitlab at salsa.debian.org
Sat Aug 25 13:02:21 CEST 2018


Chris Lamb pushed to branch master at Reproducible Builds / reproducible-website


Commits:
22c1dcb8 by Chris Lamb at 2018-08-25T11:01:54Z
Add a very simple Selenium-based functional testsuite.

- - - - -


1 changed file:

- + test


Changes:

=====================================
test
=====================================
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+
+import time
+import socket
+import unittest
+import subprocess
+import contextlib
+
+from selenium import webdriver
+from selenium.common.exceptions import NoSuchElementException
+
+PORT = 4000
+JEKYLL = None
+
+
+def setUpModule():
+    global JEKYLL
+
+    assert not port_open()
+
+    subprocess.check_call(('jekyll', 'build', '--verbose'))
+    JEKYLL = subprocess.Popen((
+        'jekyll',
+        'serve',
+        '--skip-initial-build',
+        '--port', str(PORT),
+    ))
+
+    for x in range(10):
+        time.sleep(1)
+        if port_open():
+            break
+    else:
+        assert False, "Could not find site"
+
+
+def tearDownModule():
+    global JEKYLL
+
+    JEKYLL.kill()
+
+
+def port_open():
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+    with contextlib.closing(s) as s:
+        return s.connect_ex(('127.0.0.1', PORT)) == 0
+
+
+class TestSite(unittest.TestCase):
+    def setUp(self):
+        chrome_options = webdriver.ChromeOptions()
+        chrome_options.add_argument('--no-sandbox')
+        chrome_options.add_argument('--headless')
+        chrome_options.add_argument('--disable-gpu')
+        self.driver = webdriver.Chrome(chrome_options=chrome_options)
+        self.driver.implicitly_wait(10)
+
+    def tearDown(self):
+        self.driver.quit()
+
+    def test_smoke(self):
+        try:
+            self.driver.get('http://127.0.0.1:{}'.format(PORT))
+            self.driver.find_element_by_class_name('site-header')
+        except NoSuchElementException as exc:
+            self.fail(exc.msg)
+
+
+if __name__ == '__main__':
+    suite = unittest.TestLoader().loadTestsFromTestCase(TestSite)
+    unittest.TextTestRunner(verbosity=2).run(suite)



View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/commit/22c1dcb867cf9de1d337133437da6bc51a8643ee

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/commit/22c1dcb867cf9de1d337133437da6bc51a8643ee
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20180825/5fce3ce5/attachment.html>


More information about the rb-commits mailing list