mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 11:40:58 +00:00
Adds callback for creation of an error log (#3136)
* Adds callback for creation of an error log * Fix unit tests
This commit is contained in:
@ -299,11 +299,12 @@ def trigger_notification(obj, category=None, obj_ref='pk', **kwargs):
|
||||
delivery_methods = (delivery_methods - IGNORED_NOTIFICATION_CLS)
|
||||
|
||||
for method in delivery_methods:
|
||||
logger.info(f"Triggering method '{method.METHOD_NAME}'")
|
||||
logger.info(f"Triggering notification method '{method.METHOD_NAME}'")
|
||||
try:
|
||||
deliver_notification(method, obj, category, targets, context)
|
||||
except NotImplementedError as error:
|
||||
raise error
|
||||
# Allow any single notification method to fail, without failing the others
|
||||
logger.error(error)
|
||||
except Exception as error:
|
||||
logger.error(error)
|
||||
|
||||
|
@ -93,7 +93,7 @@ class BulkNotificationMethodTests(BaseNotificationIntegrationTest):
|
||||
def get_targets(self):
|
||||
return [1, ]
|
||||
|
||||
with self.assertRaises(NotImplementedError):
|
||||
with self.assertLogs(logger='inventree', level='ERROR'):
|
||||
self._notification_run(WrongImplementation)
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ class SingleNotificationMethodTests(BaseNotificationIntegrationTest):
|
||||
def get_targets(self):
|
||||
return [1, ]
|
||||
|
||||
with self.assertRaises(NotImplementedError):
|
||||
with self.assertLogs(logger='inventree', level='ERROR'):
|
||||
self._notification_run(WrongImplementation)
|
||||
|
||||
# A integration test for notifications is provided in test_part.PartNotificationTest
|
||||
|
Reference in New Issue
Block a user