def test_known_transition_should_succeed(self): self.assertTrue(can_proceed(self.model.publish)) self.model.publish() self.assertEqual(self.model.state, 'published') self.assertTrue(can_proceed(self.model.hide)) self.model.hide() self.assertEqual(self.model.state, 'hidden')
def test_star_shortcut_succeed(self): self.assertTrue(can_proceed(self.model.moderate)) self.model.moderate() self.assertEqual(self.model.state, 'moderated')
def test_state_non_changed_after_fail(self): self.assertTrue(can_proceed(self.model.remove)) self.assertRaises(Exception, self.model.remove) self.assertEqual(self.model.state, 'new')
def test_unknow_transition_fails(self): self.assertFalse(can_proceed(self.model.hide)) self.assertRaises(TransitionNotAllowed, self.model.hide)
def test_unmet_condition(self): self.model.publish() self.assertEqual(self.model.state, 'published') self.assertFalse(can_proceed(self.model.destroy)) self.assertFalse(self.model.destroy())