mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-26 01:42:16 +00:00
Merge remote-tracking branch 'origin/bs4' into bs4
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -110,3 +110,4 @@ crashlytics.properties
|
|||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
.vscode/
|
.vscode/
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
|
screenshots/
|
||||||
@@ -247,3 +247,6 @@ RISK_ASSESSMENT_URL = os.environ.get('RISK_ASSESSMENT_URL') if os.environ.get(
|
|||||||
'RISK_ASSESSMENT_URL') else "http://example.com"
|
'RISK_ASSESSMENT_URL') else "http://example.com"
|
||||||
RISK_ASSESSMENT_SECRET = os.environ.get('RISK_ASSESSMENT_SECRET') if os.environ.get(
|
RISK_ASSESSMENT_SECRET = os.environ.get('RISK_ASSESSMENT_SECRET') if os.environ.get(
|
||||||
'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_SECRET = os.environ.get('IMGUR_UPLOAD_CLIENT_SECRET', '')
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ import os
|
|||||||
import pytz
|
import pytz
|
||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
import imgurpython
|
||||||
|
import PyRIGS.settings
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
def create_datetime(year, month, day, hour, min):
|
def create_datetime(year, month, day, hour, min):
|
||||||
@@ -47,6 +52,40 @@ class AutoLoginTest(BaseTest):
|
|||||||
loginPage.login("EventTest", "EventTestPassword")
|
loginPage.login("EventTest", "EventTestPassword")
|
||||||
|
|
||||||
|
|
||||||
|
def screenshot_failure(func):
|
||||||
|
def wrapper_func(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
func(self, *args, **kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
screenshot_name = func.__module__ + "." + func.__qualname__
|
||||||
|
screenshot_file = "screenshots/"+func.__qualname__+".png"
|
||||||
|
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,
|
||||||
|
'name': screenshot_name,
|
||||||
|
'title': screenshot_name,
|
||||||
|
'description': ""
|
||||||
|
}
|
||||||
|
client = imgurpython.ImgurClient(settings.IMGUR_UPLOAD_CLIENT_ID, settings.IMGUR_UPLOAD_CLIENT_SECRET)
|
||||||
|
image = client.upload_from_path(screenshot_file, config=config)
|
||||||
|
print("Error in test {} is at url {}".format(screenshot_name, image['link']), file=sys.stderr)
|
||||||
|
else:
|
||||||
|
print("Error in test {} is at path {}".format(screenshot_name, screenshot_file), file=sys.stderr)
|
||||||
|
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
|
# Checks if animation is done
|
||||||
class animation_is_finished(object):
|
class animation_is_finished(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from django.test import TestCase
|
|||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from PyRIGS.tests.base import BaseTest, AutoLoginTest
|
from PyRIGS.tests.base import BaseTest, AutoLoginTest, screenshot_failure_cls
|
||||||
from RIGS import models, urls
|
from RIGS import models, urls
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
@@ -25,6 +25,7 @@ from django.http import HttpResponseBadRequest
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class BaseRigboardTest(AutoLoginTest):
|
class BaseRigboardTest(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
||||||
@@ -40,6 +41,7 @@ class BaseRigboardTest(AutoLoginTest):
|
|||||||
self.assertTrue(self.page.is_expanded)
|
self.assertTrue(self.page.is_expanded)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestRigboard(BaseRigboardTest):
|
class TestRigboard(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -101,6 +103,7 @@ class TestRigboard(BaseRigboardTest):
|
|||||||
# Ideally get a response object to assert 200 on
|
# Ideally get a response object to assert 200 on
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestEventCreate(BaseRigboardTest):
|
class TestEventCreate(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -329,6 +332,7 @@ class TestEventCreate(BaseRigboardTest):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestEventDuplicate(BaseRigboardTest):
|
class TestEventDuplicate(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -428,6 +432,7 @@ class TestEventDuplicate(BaseRigboardTest):
|
|||||||
self.assertNotIn("Test Item 3", table.text)
|
self.assertNotIn("Test Item 3", table.text)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestEventEdit(BaseRigboardTest):
|
class TestEventEdit(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -488,6 +493,7 @@ class TestEventEdit(BaseRigboardTest):
|
|||||||
self.assertIn("Test Item 3", table.text)
|
self.assertIn("Test Item 3", table.text)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestEventDetail(BaseRigboardTest):
|
class TestEventDetail(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -524,6 +530,7 @@ class TestEventDetail(BaseRigboardTest):
|
|||||||
self.assertEqual(self.client.phone, None)
|
self.assertEqual(self.client.phone, None)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestCalendar(BaseRigboardTest):
|
class TestCalendar(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -709,6 +716,7 @@ class TestCalendar(BaseRigboardTest):
|
|||||||
# Wow - that was a lot of tests
|
# Wow - that was a lot of tests
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class ClientEventAuthorisationTest(TestCase):
|
class ClientEventAuthorisationTest(TestCase):
|
||||||
auth_data = {
|
auth_data = {
|
||||||
'name': 'Test ABC',
|
'name': 'Test ABC',
|
||||||
@@ -815,6 +823,7 @@ class ClientEventAuthorisationTest(TestCase):
|
|||||||
self.assertEqual(mail.outbox[1].to, [settings.AUTHORISATION_NOTIFICATION_ADDRESS])
|
self.assertEqual(mail.outbox[1].to, [settings.AUTHORISATION_NOTIFICATION_ADDRESS])
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TECEventAuthorisationTest(TestCase):
|
class TECEventAuthorisationTest(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from django.test.utils import override_settings
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from RIGS import models as rigsmodels
|
from RIGS import models as rigsmodels
|
||||||
from PyRIGS.tests.base import BaseTest, AutoLoginTest
|
from PyRIGS.tests.base import BaseTest, AutoLoginTest, screenshot_failure_cls
|
||||||
from assets import models, urls
|
from assets import models, urls
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
@@ -18,6 +18,7 @@ import datetime
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestAssetList(AutoLoginTest):
|
class TestAssetList(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -95,6 +96,7 @@ class TestAssetList(AutoLoginTest):
|
|||||||
self.assertEqual("10", assetIDs[1])
|
self.assertEqual("10", assetIDs[1])
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestAssetForm(AutoLoginTest):
|
class TestAssetForm(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -202,6 +204,7 @@ class TestAssetForm(AutoLoginTest):
|
|||||||
self.assertEqual(models.Asset.objects.last().description, self.parent.description)
|
self.assertEqual(models.Asset.objects.last().description, self.parent.description)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestSupplierList(AutoLoginTest):
|
class TestSupplierList(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -241,6 +244,7 @@ class TestSupplierList(AutoLoginTest):
|
|||||||
self.assertTrue(len(self.page.suppliers) == 0)
|
self.assertTrue(len(self.page.suppliers) == 0)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestSupplierCreateAndEdit(AutoLoginTest):
|
class TestSupplierCreateAndEdit(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -268,6 +272,7 @@ class TestSupplierCreateAndEdit(AutoLoginTest):
|
|||||||
self.assertTrue(self.page.success)
|
self.assertTrue(self.page.success)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestAssetAudit(AutoLoginTest):
|
class TestAssetAudit(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -338,6 +343,7 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
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
|
||||||
class TestSupplierValidation(TestCase):
|
class TestSupplierValidation(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@@ -360,6 +366,7 @@ class TestSupplierValidation(TestCase):
|
|||||||
self.assertFormError(response, 'form', 'name', 'This field is required.')
|
self.assertFormError(response, 'form', 'name', 'This field is required.')
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class Test404(TestCase):
|
class Test404(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@@ -379,6 +386,7 @@ class Test404(TestCase):
|
|||||||
|
|
||||||
|
|
||||||
# @tag('slow') TODO: req. Django 3.0
|
# @tag('slow') TODO: req. Django 3.0
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestAccessLevels(TestCase):
|
class TestAccessLevels(TestCase):
|
||||||
@override_settings(DEBUG=True)
|
@override_settings(DEBUG=True)
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -449,6 +457,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
|
||||||
class TestFormValidation(TestCase):
|
class TestFormValidation(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@@ -517,6 +526,7 @@ class TestFormValidation(TestCase):
|
|||||||
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
|
||||||
class TestSampleDataGenerator(TestCase):
|
class TestSampleDataGenerator(TestCase):
|
||||||
@override_settings(DEBUG=True)
|
@override_settings(DEBUG=True)
|
||||||
def test_generate_sample_data(self):
|
def test_generate_sample_data(self):
|
||||||
@@ -541,6 +551,7 @@ class TestSampleDataGenerator(TestCase):
|
|||||||
self.assertRaisesRegex(CommandError, ".*production", call_command, 'deleteSampleData')
|
self.assertRaisesRegex(CommandError, ".*production", call_command, 'deleteSampleData')
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestVersioningViews(TestCase):
|
class TestVersioningViews(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@@ -584,6 +595,7 @@ class TestVersioningViews(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
|
@screenshot_failure_cls
|
||||||
class TestEmbeddedViews(TestCase):
|
class TestEmbeddedViews(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
|||||||
@@ -23,3 +23,4 @@ simplejson==3.17.0
|
|||||||
whitenoise==5.0.1
|
whitenoise==5.0.1
|
||||||
reportlab==3.4.0
|
reportlab==3.4.0
|
||||||
z3c.rml==3.9.1
|
z3c.rml==3.9.1
|
||||||
|
imgurpython==1.1.7
|
||||||
Reference in New Issue
Block a user