mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	patch loading methods for selective loading
This commit is contained in:
		| @@ -131,8 +131,13 @@ class MethodStorageClass: | |||||||
|     liste = None |     liste = None | ||||||
|     user_settings = {} |     user_settings = {} | ||||||
|  |  | ||||||
|     def collect(self): |     def collect(self, selected_classes=None): | ||||||
|         storage.liste = inheritors(NotificationMethod) - IGNORED_NOTIFICATION_CLS |         current_method = inheritors(NotificationMethod) - IGNORED_NOTIFICATION_CLS | ||||||
|  |  | ||||||
|  |         # for testing selective loading is made available | ||||||
|  |         if selected_classes: | ||||||
|  |             current_method = [item for item in current_method if item is selected_classes] | ||||||
|  |         storage.liste = current_method | ||||||
|  |  | ||||||
|     def get_usersettings(self, user): |     def get_usersettings(self, user): | ||||||
|         methods = [] |         methods = [] | ||||||
|   | |||||||
| @@ -95,7 +95,7 @@ class BulkNotificationMethodTests(BaseNotificationIntegrationTest): | |||||||
|                 return [1, ] |                 return [1, ] | ||||||
|  |  | ||||||
|         with self.assertRaises(NotImplementedError): |         with self.assertRaises(NotImplementedError): | ||||||
|             self._notification_run() |             self._notification_run(WrongImplementation) | ||||||
|  |  | ||||||
|  |  | ||||||
| class SingleNotificationMethodTests(BaseNotificationIntegrationTest): | class SingleNotificationMethodTests(BaseNotificationIntegrationTest): | ||||||
| @@ -113,6 +113,6 @@ class SingleNotificationMethodTests(BaseNotificationIntegrationTest): | |||||||
|                 return [1, ] |                 return [1, ] | ||||||
|  |  | ||||||
|         with self.assertRaises(NotImplementedError): |         with self.assertRaises(NotImplementedError): | ||||||
|             self._notification_run() |             self._notification_run(WrongImplementation) | ||||||
|  |  | ||||||
| # A integration test for notifications is provided in test_part.PartNotificationTest | # A integration test for notifications is provided in test_part.PartNotificationTest | ||||||
|   | |||||||
| @@ -494,9 +494,13 @@ class BaseNotificationIntegrationTest(TestCase): | |||||||
|         # Define part that will be tested |         # Define part that will be tested | ||||||
|         self.part = Part.objects.get(name='R_2K2_0805') |         self.part = Part.objects.get(name='R_2K2_0805') | ||||||
|  |  | ||||||
|     def _notification_run(self): |     def _notification_run(self, run_class=None): | ||||||
|  |         """ | ||||||
|  |         Run a notification test suit through. | ||||||
|  |         If you only want to test one class pass it to run_class | ||||||
|  |         """ | ||||||
|         # reload notification methods |         # reload notification methods | ||||||
|         storage.collect() |         storage.collect(run_class) | ||||||
|  |  | ||||||
|         # There should be no notification runs |         # There should be no notification runs | ||||||
|         self.assertEqual(NotificationEntry.objects.all().count(), 0) |         self.assertEqual(NotificationEntry.objects.all().count(), 0) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user