From 40766d4fee6073c8dbcd81d037695d8e0fd68726 Mon Sep 17 00:00:00 2001 From: Gert Van Gool Date: Fri, 2 Oct 2015 16:53:35 +0200 Subject: [PATCH] Makes test_transition chainable (fixes #56) --- django_states/model_methods.py | 2 +- django_states/tests.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/django_states/model_methods.py b/django_states/model_methods.py index 8d09eef..f94ed1f 100644 --- a/django_states/model_methods.py +++ b/django_states/model_methods.py @@ -146,7 +146,7 @@ def test_transition(si_self, transition, user=None): if validation_errors: raise TransitionNotValidated(si_self, transition, validation_errors) - return True + return si_self def make_transition(si_self, transition, user=None, **kwargs): """ diff --git a/django_states/tests.py b/django_states/tests.py index fed97e9..da1a265 100644 --- a/django_states/tests.py +++ b/django_states/tests.py @@ -380,7 +380,10 @@ def test_initial_state(self): self.assertEqual(testclass.state, 'start') self.assertTrue(state_info.initial) - state_info.make_transition('start_step_1', user=self.superuser) + state_info.test_transition('start_step_1', user=self.superuser) + with self.assertRaises(PermissionDenied): + state_info.test_transition('start_step_1', user=User(username='user1')) + state_info.test_transition('start_step_1', user=self.superuser).make_transition('start_step_1', user=self.superuser) self.assertFalse(state_info.initial) def test_end_to_end(self):