From a7119599cad9e97e5d7a89858d6c273214d25c84 Mon Sep 17 00:00:00 2001 From: Arona Jones Date: Sun, 14 Feb 2021 00:00:07 +0000 Subject: [PATCH] more poking --- Pipfile | 149 ++++++++++++++++--------------- Pipfile.lock | 103 ++++++++------------- RIGS/tests/conftest.py | 9 ++ RIGS/tests/test_interaction.py | 75 ++++++++-------- assets/models.py | 1 + assets/tests/test_interaction.py | 17 ++-- conftest.py | 8 +- 7 files changed, 176 insertions(+), 186 deletions(-) diff --git a/Pipfile b/Pipfile index 596e2ea4..8da6b80a 100644 --- a/Pipfile +++ b/Pipfile @@ -4,81 +4,80 @@ verify_ssl = true name = "pypi" [packages] -ansicolors = "==1.1.8" -asgiref = "==3.3.1" -"backports.tempfile" = "==1.0" -"backports.weakref" = "==1.0.post1" -beautifulsoup4 = "==4.9.3" -Brotli = "==1.0.9" -cachetools = "==4.2.1" -certifi = "==2020.12.5" -chardet = "==4.0.0" -configparser = "==5.0.1" -contextlib2 = "==0.6.0.post1" -cssselect = "==1.1.0" -cssutils = "==1.0.2" -diff-match-patch = "==20200713" -dj-database-url = "==0.5.0" -dj-static = "==0.0.6" -Django = "==3.1.5" -django-debug-toolbar = "==3.2" -django-filter = "==2.4.0" -django-ical = "==1.7.1" -django-recaptcha = "==2.0.6" -django-recurrence = "==1.10.3" -django-registration-redux = "==2.9" -django-reversion = "==3.0.9" -django-toolbelt = "==0.0.1" -django-widget-tweaks = "==1.4.8" -django-htmlmin = "==0.11.0" -envparse = "==0.2.0" -gunicorn = "==20.0.4" -icalendar = "==4.0.7" -idna = "==2.10" -importlib-metadata = "==3.4.0" -lxml = "==4.6.2" -Markdown = "==3.3.3" -msgpack = "==1.0.2" -pep517 = "==0.9.1" -Pillow = "==8.1.0" -premailer = "==3.7.0" -progress = "==1.5" -psutil = "==5.8.0" -psycopg2 = "==2.8.6" -Pygments = "==2.7.4" -pyparsing = "==2.4.7" -PyPDF2 = "==1.26.0" -PyPOM = "==2.2.0" -python-dateutil = "==2.8.1" -pytoml = "==0.1.21" -pytz = "==2020.5" -reportlab = "==3.5.59" -requests = "==2.25.1" -retrying = "==1.3.3" -selenium = "==3.141.0" -simplejson = "==3.17.2" -six = "==1.15.0" -soupsieve = "==2.1" -sqlparse = "==0.4.1" -static3 = "==0.7.0" -svg2rlg = "==0.3" -tini = "==3.0.1" -tornado = "==6.1" -urllib3 = "==1.26.2" -whitenoise = "==5.2.0" -yolk = "==0.4.3" -"z3c.rml" = "==4.1.2" -zipp = "==3.4.0" -"zope.component" = "==4.6.2" -"zope.deferredimport" = "==4.3.1" -"zope.deprecation" = "==4.4.0" -"zope.event" = "==4.5.0" -"zope.hookable" = "==5.0.1" -"zope.interface" = "==5.2.0" -"zope.proxy" = "==4.3.5" -"zope.schema" = "==6.0.1" +ansicolors = "~=1.1.8" +asgiref = "~=3.3.1" +"backports.tempfile" = "~=1.0" +"backports.weakref" = "~=1.0.post1" +beautifulsoup4 = "~=4.9.3" +Brotli = "~=1.0.9" +cachetools = "~=4.2.1" +certifi = "~=2020.12.5" +chardet = "~=4.0.0" +configparser = "~=5.0.1" +contextlib2 = "~=0.6.0.post1" +cssselect = "~=1.1.0" +cssutils = "~=1.0.2" +dj-database-url = "~=0.5.0" +dj-static = "~=0.0.6" +Django = "~=3.1.5" +django-debug-toolbar = "~=3.2" +django-filter = "~=2.4.0" +django-ical = "~=1.7.1" +django-recaptcha = "~=2.0.6" +django-recurrence = "~=1.10.3" +django-registration-redux = "~=2.9" +django-reversion = "~=3.0.9" +django-toolbelt = "~=0.0.1" +django-widget-tweaks = "~=1.4.8" +django-htmlmin = "~=0.11.0" +envparse = "~=0.2.0" +gunicorn = "~=20.0.4" +icalendar = "~=4.0.7" +idna = "~=2.10" +importlib-metadata = "~=3.4.0" +lxml = "~=4.6.2" +Markdown = "~=3.3.3" +msgpack = "~=1.0.2" +pep517 = "~=0.9.1" +Pillow = "~=8.1.0" +premailer = "~=3.7.0" +progress = "~=1.5" +psutil = "~=5.8.0" +psycopg2 = "~=2.8.6" +Pygments = "~=2.7.4" +pyparsing = "~=2.4.7" +PyPDF2 = "~=1.26.0" +PyPOM = "~=2.2.0" +python-dateutil = "~=2.8.1" +pytoml = "~=0.1.21" +pytz = "~=2020.5" +reportlab = "~=3.5.59" +requests = "~=2.25.1" +retrying = "~=1.3.3" +selenium = "~=3.141.0" +simplejson = "~=3.17.2" +six = "~=1.15.0" +soupsieve = "~=2.1" +sqlparse = "~=0.4.1" +static3 = "~=0.7.0" +svg2rlg = "~=0.3" +tini = "~=3.0.1" +tornado = "~=6.1" +urllib3 = "~=1.26.2" +whitenoise = "~=5.2.0" +yolk = "~=0.4.3" +"z3c.rml" = "~=4.1.2" +zipp = "~=3.4.0" +"zope.component" = "~=4.6.2" +"zope.deferredimport" = "~=4.3.1" +"zope.deprecation" = "~=4.4.0" +"zope.event" = "~=4.5.0" +"zope.hookable" = "~=5.0.1" +"zope.interface" = "~=5.2.0" +"zope.proxy" = "~=4.3.5" +"zope.schema" = "~=6.0.1" sentry-sdk = "*" -pytest-splinter = "*" +diff-match-patch = "*" [dev-packages] pycodestyle = "*" @@ -88,6 +87,8 @@ pytest-cov = "*" pytest-django = "*" pytest-xdist = "*" pluggy = "*" +pytest-splinter = "*" +pytest = "*" [requires] python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock index 248ac76a..648e6c33 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "5829b746578681f0e8c44e47a0a07d896b2626923f2986ef51e6198dc069e508" + "sha256": "472e927edcfd6141d88f3be8c51255c0de63d42987382aa472cf68557a00b089" }, "pipfile-spec": 6, "requires": { @@ -32,14 +32,6 @@ "index": "pypi", "version": "==3.3.1" }, - "attrs": { - "hashes": [ - "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6", - "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.3.0" - }, "backports.tempfile": { "hashes": [ "sha256:05aa50940946f05759696156a8c39be118169a0e0f94a49d0bb106503891ff54", @@ -184,11 +176,11 @@ }, "django": { "hashes": [ - "sha256:2d78425ba74c7a1a74b196058b261b9733a8570782f4e2828974777ccca7edf7", - "sha256:efa2ab96b33b20c2182db93147a0c3cd7769d418926f9e9f140a60dca7c64ca9" + "sha256:169e2e7b4839a7910b393eec127fd7cbae62e80fa55f89c6510426abf673fe5f", + "sha256:c6c0462b8b361f8691171af1fb87eceb4442da28477e12200c40420176206ba7" ], "index": "pypi", - "version": "==3.1.5" + "version": "==3.1.6" }, "django-debug-toolbar": { "hashes": [ @@ -314,13 +306,6 @@ "index": "pypi", "version": "==3.4.0" }, - "iniconfig": { - "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" - ], - "version": "==1.1.1" - }, "lxml": { "hashes": [ "sha256:0448576c148c129594d890265b1a83b9cd76fd1f0a6a04620753d9a6bcfd0a4d", @@ -406,14 +391,6 @@ "index": "pypi", "version": "==1.0.2" }, - "packaging": { - "hashes": [ - "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5", - "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.9" - }, "pep517": { "hashes": [ "sha256:3985b91ebf576883efe5fa501f42a16de2607684f3797ddba7202b71b7d0da51", @@ -567,14 +544,6 @@ "index": "pypi", "version": "==2.8.6" }, - "py": { - "hashes": [ - "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", - "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.10.0" - }, "pygments": { "hashes": [ "sha256:bc9591213a8f0e0ca1a5e68a479b4887fdc3e75d0774e5c71c31920c427de435", @@ -606,21 +575,6 @@ "index": "pypi", "version": "==2.2.0" }, - "pytest": { - "hashes": [ - "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9", - "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839" - ], - "markers": "python_version >= '3.6'", - "version": "==6.2.2" - }, - "pytest-splinter": { - "hashes": [ - "sha256:16d93db719bcad19342935c1707b5c3ec7e34d9ae10df683f6fc2e9e982ddb39" - ], - "index": "pypi", - "version": "==3.3.1" - }, "python-dateutil": { "hashes": [ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", @@ -782,18 +736,11 @@ }, "soupsieve": { "hashes": [ - "sha256:4bb21a6ee4707bf43b61230e80740e71bfe56e55d1f1f50924b087bb2975c851", - "sha256:6dc52924dc0bc710a5d16794e6b3480b2c7c08b07729505feab2b2c16661ff6e" + "sha256:407fa1e8eb3458d1b5614df51d9651a1180ea5fedf07feb46e45d7e25e6d6cdd", + "sha256:d3a5ea5b350423f47d07639f74475afedad48cf41c0ad7a82ca13a3928af34f6" ], "index": "pypi", - "version": "==2.1" - }, - "splinter": { - "hashes": [ - "sha256:459e39e7a9f7572db6f1cdb5fdc5ccfc6404f021dccb969ee6287be2386a40db", - "sha256:7e5e69c5b76ada909283465cdc3636e2632f7e557932ce96ab9c0432b0b32f7f" - ], - "version": "==0.14.0" + "version": "==2.2" }, "sqlparse": { "hashes": [ @@ -882,11 +829,11 @@ }, "urllib3": { "hashes": [ - "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08", - "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473" + "sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80", + "sha256:de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73" ], "index": "pypi", - "version": "==1.26.2" + "version": "==1.26.3" }, "webencodings": { "hashes": [ @@ -1293,7 +1240,7 @@ "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9", "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839" ], - "markers": "python_version >= '3.6'", + "index": "pypi", "version": "==6.2.2" }, "pytest-cov": { @@ -1320,6 +1267,13 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==1.3.0" }, + "pytest-splinter": { + "hashes": [ + "sha256:16d93db719bcad19342935c1707b5c3ec7e34d9ae10df683f6fc2e9e982ddb39" + ], + "index": "pypi", + "version": "==3.3.1" + }, "pytest-xdist": { "hashes": [ "sha256:2447a1592ab41745955fb870ac7023026f20a5f0bfccf1b52a879bd193d46450", @@ -1336,6 +1290,14 @@ "index": "pypi", "version": "==2.25.1" }, + "selenium": { + "hashes": [ + "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c", + "sha256:deaf32b60ad91a4611b98d8002757f29e6f2c2d5fcaf202e1c9ad06d6772300d" + ], + "index": "pypi", + "version": "==3.141.0" + }, "six": { "hashes": [ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", @@ -1344,6 +1306,13 @@ "index": "pypi", "version": "==1.15.0" }, + "splinter": { + "hashes": [ + "sha256:459e39e7a9f7572db6f1cdb5fdc5ccfc6404f021dccb969ee6287be2386a40db", + "sha256:7e5e69c5b76ada909283465cdc3636e2632f7e557932ce96ab9c0432b0b32f7f" + ], + "version": "==0.14.0" + }, "toml": { "hashes": [ "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", @@ -1354,11 +1323,11 @@ }, "urllib3": { "hashes": [ - "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08", - "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473" + "sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80", + "sha256:de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73" ], "index": "pypi", - "version": "==1.26.2" + "version": "==1.26.3" } } } diff --git a/RIGS/tests/conftest.py b/RIGS/tests/conftest.py index f617c46e..8365f645 100644 --- a/RIGS/tests/conftest.py +++ b/RIGS/tests/conftest.py @@ -25,6 +25,15 @@ def ra(basic_event, admin_user): ra.delete() +@pytest.fixture +def medium_ra(ra): + ra.big_power = True + ra.save() + yield ra + ra.big_power = False + ra.save() + + @pytest.fixture def venue(db): venue = models.Venue.objects.create(name="Venue 1") diff --git a/RIGS/tests/test_interaction.py b/RIGS/tests/test_interaction.py index 7f070716..201713b0 100644 --- a/RIGS/tests/test_interaction.py +++ b/RIGS/tests/test_interaction.py @@ -666,6 +666,44 @@ def test_ra_edit(logged_in_browser, live_server, ra): assert ra.nonstandard_equipment == nse +def test_ec_create_medium(logged_in_browser, live_server, admin_user, medium_ra): + page = pages.CreateEventChecklist(logged_in_browser.driver, live_server.url, event_id=medium_ra.event.pk).open() + + page.safe_parking = True + page.safe_packing = True + page.exits = True + page.trip_hazard = True + page.warning_signs = True + page.ear_plugs = True + page.hs_location = "Death Valley" + page.extinguishers_location = "With the rest of the fire" + # If we do this first the search fails, for ... reasons + page.power_mic.search(admin_user.name) + page.power_mic.toggle() + assert not page.power_mic.is_open + + # Gotta scroll to make the button clickable + logged_in_browser.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") + + page.earthing = True + page.pat = True + page.source_rcd = True + page.labelling = True + page.fd_voltage_l1 = 240 + page.fd_voltage_l2 = 235 + page.fd_voltage_l3 = 0 + page.fd_phase_rotation = True + page.fd_earth_fault = 666 + page.fd_pssc = 1984 + page.w1_description = "In the carpark, by the bins" + page.w1_polarity = True + page.w1_voltage = 240 + page.w1_earth_fault = 333 + + page.submit() + assert page.success + + @screenshot_failure_cls class TestHealthAndSafety(BaseRigboardTest): def setUp(self): @@ -818,43 +856,6 @@ class TestHealthAndSafety(BaseRigboardTest): self.page.submit() self.assertTrue(self.page.success) - def test_ec_create_medium(self): - self.page = pages.CreateEventChecklist(self.driver, self.live_server_url, event_id=self.testEvent3.pk).open() - - self.page.safe_parking = True - self.page.safe_packing = True - self.page.exits = True - self.page.trip_hazard = True - self.page.warning_signs = True - self.page.ear_plugs = True - self.page.hs_location = "Death Valley" - self.page.extinguishers_location = "With the rest of the fire" - # If we do this first the search fails, for ... reasons - self.page.power_mic.search(self.profile.name) - self.page.power_mic.toggle() - self.assertFalse(self.page.power_mic.is_open) - - # Gotta scroll to make the button clickable - self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") - - self.page.earthing = True - self.page.pat = True - self.page.source_rcd = True - self.page.labelling = True - self.page.fd_voltage_l1 = 240 - self.page.fd_voltage_l2 = 235 - self.page.fd_voltage_l3 = 0 - self.page.fd_phase_rotation = True - self.page.fd_earth_fault = 666 - self.page.fd_pssc = 1984 - self.page.w1_description = "In the carpark, by the bins" - self.page.w1_polarity = True - self.page.w1_voltage = 240 - self.page.w1_earth_fault = 333 - - self.page.submit() - self.assertTrue(self.page.success) - def test_ec_create_extras(self): eid = self.testEvent2.pk self.page = pages.CreateEventChecklist(self.driver, self.live_server_url, event_id=eid).open() diff --git a/assets/models.py b/assets/models.py index 0b783865..bf662ccc 100644 --- a/assets/models.py +++ b/assets/models.py @@ -99,6 +99,7 @@ def get_available_asset_id(wanted_prefix=""): return 9000 else: return row[0] + cursor.close() @reversion.register diff --git a/assets/tests/test_interaction.py b/assets/tests/test_interaction.py index eb45129e..81caba48 100644 --- a/assets/tests/test_interaction.py +++ b/assets/tests/test_interaction.py @@ -273,6 +273,16 @@ class TestSupplierCreateAndEdit(AutoLoginTest): self.assertTrue(self.page.success) +def test_audit_search(logged_in_browser, live_server): + page = pages.AssetAuditList(logged_in_browser.driver, live_server.url).open() + # Check that a failed search works + page.set_query("NOTFOUND") + page.search() + assert not logged_in_browser.find_by_id('modal').visible + logged_in_browser.driver.implicitly_wait(4) + assert "Asset with that ID does not exist!" in page.error.text + + @screenshot_failure_cls class TestAssetAudit(AutoLoginTest): def setUp(self): @@ -336,10 +346,3 @@ class TestAssetAudit(AutoLoginTest): # Make sure audit log was NOT filled out audited = models.Asset.objects.get(asset_id=asset_row.id) assert audited.last_audited_by is None - - def test_audit_search(self): - # Check that a failed search works - self.page.set_query("NOTFOUND") - self.page.search() - self.assertFalse(self.driver.find_element_by_id('modal').is_displayed()) - self.assertIn("Asset with that ID does not exist!", self.page.error.text) diff --git a/conftest.py b/conftest.py index 37ad4674..335d6057 100644 --- a/conftest.py +++ b/conftest.py @@ -24,11 +24,17 @@ def pytest_configure(): @pytest.fixture -def logged_in_browser(live_server, browser): +def profile(db): profile = Profile( username="EventTest", first_name="Event", last_name="Test", initials="ETU", is_superuser=True) profile.set_password("EventTestPassword") profile.save() + yield profile + profile.delete() + + +@pytest.fixture +def logged_in_browser(live_server, browser, profile): login_page = pages.LoginPage(browser.driver, live_server.url).open() login_page.login("EventTest", "EventTestPassword") return browser