示例#1
0
    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')
示例#2
0
 def test_star_shortcut_succeed(self):
     self.assertTrue(can_proceed(self.model.moderate))
     self.model.moderate()
     self.assertEqual(self.model.state, 'moderated')
示例#3
0
 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')
示例#4
0
 def test_unknow_transition_fails(self):
     self.assertFalse(can_proceed(self.model.hide))
     self.assertRaises(TransitionNotAllowed, self.model.hide)
示例#5
0
 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())