From 79bab93afc8807f3f2532eced7c4e43e12b66bef Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 3 Dec 2021 02:01:17 +0100 Subject: [PATCH] refactor into new test file --- InvenTree/common/test_notifications.py | 45 ++++++++++++++++++++++++++ InvenTree/common/tests.py | 43 ------------------------ 2 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 InvenTree/common/test_notifications.py diff --git a/InvenTree/common/test_notifications.py b/InvenTree/common/test_notifications.py new file mode 100644 index 0000000000..99a12a52a0 --- /dev/null +++ b/InvenTree/common/test_notifications.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from .notifications import NotificationMethod, SingleNotificationMethod, BulkNotificationMethod +from part.test_part import BaseNotificationIntegrationTest + + +class NotificationTests(BaseNotificationIntegrationTest): + + def test_NotificationMethod(self): + """ensure the implementation requirements are tested""" + + class FalseNotificationMethod(NotificationMethod): + pass + + class AnotherFalseNotificationMethod(NotificationMethod): + def send(self): + pass + + with self.assertRaises(NotImplementedError): + FalseNotificationMethod('', '', '') + + with self.assertRaises(NotImplementedError): + AnotherFalseNotificationMethod('', '', '') + + def test_SingleNotificationMethod(self): + """ensure the implementation requirements are tested""" + + class WrongImplementation(SingleNotificationMethod): + pass + + with self.assertRaises(NotImplementedError): + self._notification_run() + + def test_BulkNotificationMethod(self): + """ensure the implementation requirements are tested""" + + class WrongImplementation(BulkNotificationMethod): + pass + + with self.assertRaises(NotImplementedError): + self._notification_run() + + +# A integration test for notifications is provided in test_part.PartNotificationTest diff --git a/InvenTree/common/tests.py b/InvenTree/common/tests.py index 9138af7cf0..48838415b5 100644 --- a/InvenTree/common/tests.py +++ b/InvenTree/common/tests.py @@ -8,9 +8,6 @@ from django.contrib.auth import get_user_model from .models import InvenTreeSetting from .models import NotificationEntry -from .notifications import NotificationMethod, SingleNotificationMethod, BulkNotificationMethod - -from part.test_part import BaseNotificationIntegrationTest class SettingsTest(TestCase): @@ -111,43 +108,3 @@ class NotificationEntryTest(TestCase): self.assertFalse(NotificationEntry.check_recent('test.notification2', 1, delta)) self.assertTrue(NotificationEntry.check_recent('test.notification', 1, delta)) - - -class NotificationTests(BaseNotificationIntegrationTest): - - def test_NotificationMethod(self): - """ensure the implementation requirements are tested""" - - class FalseNotificationMethod(NotificationMethod): - pass - - class AnotherFalseNotificationMethod(NotificationMethod): - def send(self): - pass - - with self.assertRaises(NotImplementedError): - FalseNotificationMethod('', '', '') - - with self.assertRaises(NotImplementedError): - AnotherFalseNotificationMethod('', '', '') - - def test_SingleNotificationMethod(self): - """ensure the implementation requirements are tested""" - - class WrongImplementation(SingleNotificationMethod): - pass - - with self.assertRaises(NotImplementedError): - self._notification_run() - - def test_BulkNotificationMethod(self): - """ensure the implementation requirements are tested""" - - class WrongImplementation(BulkNotificationMethod): - pass - - with self.assertRaises(NotImplementedError): - self._notification_run() - - -# A integration test for notifications is provided in test_part.PartNotificationTest