def test_register_for_an_object(self): self.test_args = None self.test_kwargs = None def test_handler(*args, **kwargs): self.test_args = args self.test_kwargs = kwargs ObjectService.register_object(self.objects[0], self.field) ObjectService.register_object(self.objects[1], self.field) PostCompletedHandler.register(test_handler, self.objects[0], 'my_field') self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.field, self.user1) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) # Proceeded but no transition TransitionService.proceed(self.objects[0], self.field, self.user2) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.field, self.user3) self.assertEqual((self.objects[0], 'my_field'), self.test_args)
def test_register_for_an_object(self): self.test_args = None self.test_kwargs = None def test_handler(*args, **kwargs): self.test_args = args self.test_kwargs = kwargs ObjectService.register_object(self.objects[0], self.field) ObjectService.register_object(self.objects[1], self.field) PostCompletedHandler.register(test_handler, self.objects[0], 'my_field') self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.approve_transition(self.objects[0], self.field, self.user1) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) # Approved but no transition TransitionService.approve_transition(self.objects[0], self.field, self.user2) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.approve_transition(self.objects[0], self.field, self.user3) self.assertEqual((self.objects[0], 'my_field'), self.test_args)
def test_register_for_all(self): self.initialize_normal_scenario() self.test_args = None self.test_kwargs = None def test_handler(*args, **kwargs): self.test_args = args self.test_kwargs = kwargs ObjectService.register_object(self.objects[0]) ObjectService.register_object(self.objects[1]) PostCompletedHandler.register(test_handler) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.user1) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) # Proceeded but no transition TransitionService.proceed(self.objects[0], self.user2) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.user3) self.assertEqual((), self.test_args) self.assertDictEqual({"object": self.objects[0]}, self.test_kwargs)
def test_register_for_all(self): self.initialize_normal_scenario() self.test_args = None self.test_kwargs = None def test_handler(*args, **kwargs): self.test_args = args self.test_kwargs = kwargs ObjectService.register_object(self.objects[0]) ObjectService.register_object(self.objects[1]) PostCompletedHandler.register(test_handler) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.user1) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) # Proceeded but no transition TransitionService.proceed(self.objects[0], self.user2) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.user3) self.assertEqual((), self.test_args) self.assertDictEqual({'object': self.objects[0]}, self.test_kwargs)
def test_register_for_all(self): self.test_args = None self.test_kwargs = None def test_handler(*args, **kwargs): self.test_args = args self.test_kwargs = kwargs ObjectService.register_object(self.objects[0], self.field) ObjectService.register_object(self.objects[1], self.field) PostCompletedHandler.register(test_handler) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.approve_transition(self.objects[0], self.field, self.user1) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) # Approved but no transition TransitionService.approve_transition(self.objects[0], self.field, self.user2) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.approve_transition(self.objects[0], self.field, self.user3) self.assertEqual((), self.test_args) self.assertDictEqual( { 'field': 'my_field', 'object': self.objects[0] }, self.test_kwargs)
def test_register_for_all(self): self.test_args = None self.test_kwargs = None def test_handler(*args, **kwargs): self.test_args = args self.test_kwargs = kwargs ObjectService.register_object(self.objects[0], self.field) ObjectService.register_object(self.objects[1], self.field) PostCompletedHandler.register(test_handler) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.field, self.user1) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) # Proceeded but no transition TransitionService.proceed(self.objects[0], self.field, self.user2) self.assertIsNone(self.test_args) self.assertIsNone(self.test_kwargs) TransitionService.proceed(self.objects[0], self.field, self.user3) self.assertEqual((), self.test_args) self.assertDictEqual({ 'field': 'my_field', 'object': self.objects[0] }, self.test_kwargs)