3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),'..','..')))
6 from model import action
11 class UnprocessedStatusBehaviour(unittest.TestCase):
13 self.status = action.unprocessed
15 def test_should_return_active_on_update(self):
16 self.assertEqual(self.status.update(None),action.active)
20 class ActionBehaviour(unittest.TestCase):
23 self.action = model.action.Action(u'oldey',u'some_context')
24 self.observer = Mock()
25 self.action.observers.append(self.observer)
27 def test_should_be_unprocessed_by_default(self):
28 self.assertEqual(self.action.status,action.unprocessed)
30 def test_should_have_new_field_value_when_set(self):
31 self.action.description=u'newey'
32 assert self.action.description == u'newey'
34 def test_should_notify_observers_when_field_is_changed_externally(self):
35 self.action.description=u'newea'
36 self.observer.notify.assert_called_with(self.action,'description',new='newea',old='oldey')
38 def test_should_notify_observers_when_status_changes(self):
39 self.action.status = action.active
40 self.observer.notify.assert_called_with(self.action,'status',new=action.active,old=action.unprocessed)
44 class ActionParseBehaviour(unittest.TestCase):
47 self.description = u'some action'
48 self.context = u'context/sub_context'
49 self.info = u'additional stuff'
50 self.status_string = '-'
51 self.action = model.action.Action.parse(u'%s %s %s (%s)'%(self.status_string,self.context,self.description,self.info))
53 def test_should_read_the_description_correctly(self):
54 self.assertEqual(self.action.description, self.description)
56 def test_should_read_the_context_correctly(self):
57 self.assertEqual(self.action.context, self.context)
59 def test_should_read_the_status_correctly(self):
60 self.assertEqual(self.action.status, action.active)
62 def test_should_read_the_info_correctly(self):
63 self.assertEqual(self.action.info, self.info)