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