def test_can_serialize_links(self): task = AgiloTicket(self.env, t_type=Type.TASK) task.insert() story = AgiloTicket(self.env, t_type=Type.USER_STORY) story.link_to(task) story.insert() self.assert_equals([task.id], story.as_dict()['outgoing_links']) self.assert_equals([story.id], task.as_dict()['incoming_links'])
def test_always_serialize_id_as_int(self): task = AgiloTicket(self.env, t_type=Type.TASK) task.insert() task_id = task.id task = AgiloTicket(self.env, str(task_id)) self.assert_equals(task_id, task.as_dict()['id'])
def test_can_serialize_calculated_fields(self): story = AgiloTicket(self.env, t_type=Type.USER_STORY) task = AgiloTicket(self.env, t_type=Type.TASK) task[Key.REMAINING_TIME] = '5' story.link_to(task) story.insert() self.assert_equals(5, story.as_dict()[Key.TOTAL_REMAINING_TIME])
def test_can_serialize_task_to_dict(self): task = AgiloTicket(self.env, t_type=Type.TASK) self.assertNotEqual('fixed', task[Key.RESOLUTION]) task[Key.SUMMARY] = 'My Summary' task.insert() expected = { # required Key.ID: task.id, Key.TYPE: Type.TASK, Key.SUMMARY: 'My Summary', Key.DESCRIPTION: '', Key.STATUS: '', Key.RESOLUTION: '', Key.REPORTER: '', Key.OWNER: '', # type specific Key.SPRINT: '', Key.REMAINING_TIME: '', Key.RESOURCES: '', # Key.Options is not used in order to reduce required data to # transfer for a backlog load. 'outgoing_links': [], 'incoming_links': [], 'time_of_last_change': to_timestamp(task.time_changed), 'ts': str(task.time_changed), } if AgiloTicketSystem.is_trac_1_0(): from trac.util.datefmt import to_utimestamp expected.update( {'view_time': str(to_utimestamp(task.time_changed))}) self.assert_equals(expected, task.as_dict())
def test_can_serialize_task_to_dict(self): task = AgiloTicket(self.env, t_type=Type.TASK) self.assertNotEqual('fixed', task[Key.RESOLUTION]) task[Key.SUMMARY] = 'My Summary' task.insert() expected = { # required Key.ID: task.id, Key.TYPE: Type.TASK, Key.SUMMARY: 'My Summary', Key.DESCRIPTION: '', Key.STATUS: '', Key.RESOLUTION: '', Key.REPORTER: '', Key.OWNER: '', # type specific Key.SPRINT: '', Key.REMAINING_TIME: '', Key.RESOURCES: '', # Key.Options is not used in order to reduce required data to # transfer for a backlog load. 'outgoing_links': [], 'incoming_links': [], 'time_of_last_change': to_timestamp(task.time_changed), 'ts': str(task.time_changed), } if AgiloTicketSystem.is_trac_1_0(): from trac.util.datefmt import to_utimestamp expected.update({'view_time': str(to_utimestamp(task.time_changed))}) self.assert_equals(expected, task.as_dict())