From 58f0838d3dda37bf3c3ea8ab0e1653c7f237149e Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 4 Dec 2021 17:24:41 +0100 Subject: [PATCH] improve coverage --- InvenTree/common/test_notifications.py | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/InvenTree/common/test_notifications.py b/InvenTree/common/test_notifications.py index 169e43c09e..846d1fba09 100644 --- a/InvenTree/common/test_notifications.py +++ b/InvenTree/common/test_notifications.py @@ -20,20 +20,39 @@ class NotificationTests(BaseNotificationIntegrationTest): """a comment so we do not need a pass""" class NoNameNotificationMethod(NotificationMethod): - pass + + def send(self): + """a comment so we do not need a pass""" + + class WrongContextNotificationMethod(NotificationMethod): + METHOD_NAME = 'WrongContextNotification' + CONTEXT_EXTRA = [ + 'aa', + ('aa', 'bb', ), + ('templates', 'ccc', ), + (123, ) + ] + + def send(self): + """a comment so we do not need a pass""" # no send / send bulk with self.assertRaises(NotImplementedError): FalseNotificationMethod('', '', '', '', ) - # no gathering - with self.assertRaises(NotImplementedError): - AnotherFalseNotificationMethod('', '', '', '', ) - # no METHOD_NAME with self.assertRaises(NotImplementedError): NoNameNotificationMethod('', '', '', '', ) + # a not existant context check + with self.assertRaises(NotImplementedError): + WrongContextNotificationMethod('', '', '', '', ) + + # no get_targets + with self.assertRaises(NotImplementedError): + AnotherFalseNotificationMethod('', '', '', {'name': 1, 'message': 2, } ) + + def test_SingleNotificationMethod(self): """ensure the implementation requirements are tested"""