mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Fixed Pep8 - I promise I'll make a pre-commit hook sometime!
This commit is contained in:
@@ -249,4 +249,4 @@ RISK_ASSESSMENT_SECRET = os.environ.get('RISK_ASSESSMENT_SECRET') if os.environ.
|
||||
'RISK_ASSESSMENT_SECRET') else secrets.token_hex(15)
|
||||
|
||||
IMGUR_UPLOAD_CLIENT_ID = os.environ.get('IMGUR_UPLOAD_CLIENT_ID', '')
|
||||
IMGUR_UPLOAD_CLIENT_SECRET = os.environ.get('IMGUR_UPLOAD_CLIENT_SECRET', '')
|
||||
IMGUR_UPLOAD_CLIENT_SECRET = os.environ.get('IMGUR_UPLOAD_CLIENT_SECRET', '')
|
||||
|
||||
@@ -62,7 +62,7 @@ def screenshot_failure(func):
|
||||
if not pathlib.Path("screenshots").is_dir():
|
||||
os.mkdir("screenshots")
|
||||
self.driver.save_screenshot(screenshot_file)
|
||||
|
||||
|
||||
if settings.IMGUR_UPLOAD_CLIENT_ID != "":
|
||||
config = {
|
||||
'album': None,
|
||||
@@ -78,12 +78,14 @@ def screenshot_failure(func):
|
||||
raise e
|
||||
return wrapper_func
|
||||
|
||||
|
||||
def screenshot_failure_cls(cls):
|
||||
for attr in cls.__dict__:
|
||||
if callable(getattr(cls, attr)) and attr.startswith("test"):
|
||||
setattr(cls, attr, screenshot_failure(getattr(cls, attr)))
|
||||
return cls
|
||||
|
||||
|
||||
# Checks if animation is done
|
||||
class animation_is_finished(object):
|
||||
def __init__(self):
|
||||
|
||||
@@ -24,6 +24,7 @@ from django.core import mail, signing
|
||||
from django.http import HttpResponseBadRequest
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class BaseRigboardTest(AutoLoginTest):
|
||||
def setUp(self):
|
||||
@@ -39,6 +40,7 @@ class BaseRigboardTest(AutoLoginTest):
|
||||
self.wait.until(animation_is_finished())
|
||||
self.assertTrue(self.page.is_expanded)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestRigboard(BaseRigboardTest):
|
||||
def setUp(self):
|
||||
@@ -100,6 +102,7 @@ class TestRigboard(BaseRigboardTest):
|
||||
self.assertIn('create', self.driver.current_url)
|
||||
# Ideally get a response object to assert 200 on
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestEventCreate(BaseRigboardTest):
|
||||
def setUp(self):
|
||||
@@ -328,6 +331,7 @@ class TestEventCreate(BaseRigboardTest):
|
||||
def test_subhire_creation(self):
|
||||
pass
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestEventDuplicate(BaseRigboardTest):
|
||||
def setUp(self):
|
||||
@@ -427,6 +431,7 @@ class TestEventDuplicate(BaseRigboardTest):
|
||||
self.assertIn("Test Item 2", table.text)
|
||||
self.assertNotIn("Test Item 3", table.text)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestEventEdit(BaseRigboardTest):
|
||||
def setUp(self):
|
||||
@@ -487,6 +492,7 @@ class TestEventEdit(BaseRigboardTest):
|
||||
table = self.page.item_table
|
||||
self.assertIn("Test Item 3", table.text)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestEventDetail(BaseRigboardTest):
|
||||
def setUp(self):
|
||||
@@ -523,6 +529,7 @@ class TestEventDetail(BaseRigboardTest):
|
||||
self.assertEqual(self.client.email, self.page.email)
|
||||
self.assertEqual(self.client.phone, None)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestCalendar(BaseRigboardTest):
|
||||
def setUp(self):
|
||||
@@ -708,6 +715,7 @@ class TestCalendar(BaseRigboardTest):
|
||||
|
||||
# Wow - that was a lot of tests
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class ClientEventAuthorisationTest(TestCase):
|
||||
auth_data = {
|
||||
@@ -814,6 +822,7 @@ class ClientEventAuthorisationTest(TestCase):
|
||||
self.assertEqual(mail.outbox[0].to, ['authemail@function.test'])
|
||||
self.assertEqual(mail.outbox[1].to, [settings.AUTHORISATION_NOTIFICATION_ADDRESS])
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TECEventAuthorisationTest(TestCase):
|
||||
@classmethod
|
||||
|
||||
@@ -17,6 +17,7 @@ from PyRIGS.tests.base import animation_is_finished
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestAssetList(AutoLoginTest):
|
||||
def setUp(self):
|
||||
@@ -40,7 +41,6 @@ class TestAssetList(AutoLoginTest):
|
||||
self.assertIn("A light", assetDescriptions)
|
||||
self.assertIn("Working Mic", assetDescriptions)
|
||||
|
||||
|
||||
def test_asset_order(self):
|
||||
# Only the working stuff should be shown initially
|
||||
self.page.status_selector.open()
|
||||
@@ -95,6 +95,7 @@ class TestAssetList(AutoLoginTest):
|
||||
self.assertEqual("1", assetIDs[0])
|
||||
self.assertEqual("10", assetIDs[1])
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestAssetForm(AutoLoginTest):
|
||||
def setUp(self):
|
||||
@@ -202,6 +203,7 @@ class TestAssetForm(AutoLoginTest):
|
||||
self.assertTrue(self.page.success)
|
||||
self.assertEqual(models.Asset.objects.last().description, self.parent.description)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestSupplierList(AutoLoginTest):
|
||||
def setUp(self):
|
||||
@@ -241,6 +243,7 @@ class TestSupplierList(AutoLoginTest):
|
||||
self.page.search()
|
||||
self.assertTrue(len(self.page.suppliers) == 0)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestSupplierCreateAndEdit(AutoLoginTest):
|
||||
def setUp(self):
|
||||
@@ -268,6 +271,7 @@ class TestSupplierCreateAndEdit(AutoLoginTest):
|
||||
self.page.submit()
|
||||
self.assertTrue(self.page.success)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestAssetAudit(AutoLoginTest):
|
||||
def setUp(self):
|
||||
@@ -338,6 +342,7 @@ class TestAssetAudit(AutoLoginTest):
|
||||
self.assertFalse(self.driver.find_element_by_id('modal').is_displayed())
|
||||
self.assertIn("Asset with that ID does not exist!", self.page.error.text)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestSupplierValidation(TestCase):
|
||||
@classmethod
|
||||
@@ -360,6 +365,7 @@ class TestSupplierValidation(TestCase):
|
||||
response = self.client.post(url, {'name': ""})
|
||||
self.assertFormError(response, 'form', 'name', 'This field is required.')
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class Test404(TestCase):
|
||||
@classmethod
|
||||
@@ -450,6 +456,7 @@ class TestAccessLevels(TestCase):
|
||||
|
||||
# def test_finance_access(self): Level not used in assets currently
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestFormValidation(TestCase):
|
||||
@classmethod
|
||||
@@ -518,6 +525,7 @@ class TestFormValidation(TestCase):
|
||||
self.assertFormError(response, 'form', 'length', 'The length of a cable must be more than 0')
|
||||
self.assertFormError(response, 'form', 'csa', 'The CSA of a cable must be more than 0')
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestSampleDataGenerator(TestCase):
|
||||
@override_settings(DEBUG=True)
|
||||
@@ -542,6 +550,7 @@ class TestSampleDataGenerator(TestCase):
|
||||
self.assertRaisesRegex(CommandError, ".*production", call_command, 'generateSampleAssetsData')
|
||||
self.assertRaisesRegex(CommandError, ".*production", call_command, 'deleteSampleData')
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestVersioningViews(TestCase):
|
||||
@classmethod
|
||||
@@ -585,6 +594,7 @@ class TestVersioningViews(TestCase):
|
||||
response = self.client.get(request_url, follow=True)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
class TestEmbeddedViews(TestCase):
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user