def setUp(self): self.super() self.task = AgiloTicket(self.env, t_type=Type.TASK) # this task is not stored in the db on purpose - so I can check # that no workflow does any permanent damage! del self.task._old[Key.TYPE] req = self.teh.mock_request('foo') self.manipulator = TicketStatusManipulator(self.env, req, self.task) self.assert_equals({}, self.task._old)
def _simulate_status_change_and_update_request_parameters(self, req, args, ticket_id): # TicketStatusManipulator will change the ticket and we don't want to pollute # the cache ticket = self._ticket_without_cache(ticket_id) wrapped_request = RequestWrapper(req, args) wrapped_request.authname = self._get_username_of_acting_user(req, args, ticket) manipulator = TicketStatusManipulator(self.env, wrapped_request, ticket) ticket_changed = manipulator.change_status_to(args['simple_status']) if ticket_changed: for attribute_name in ticket._old: args[attribute_name] = ticket[attribute_name]
def _simulate_status_change_and_update_request_parameters( self, req, args, ticket_id): # TicketStatusManipulator will change the ticket and we don't want to pollute # the cache ticket = self._ticket_without_cache(ticket_id) wrapped_request = RequestWrapper(req, args) wrapped_request.authname = self._get_username_of_acting_user( req, args, ticket) manipulator = TicketStatusManipulator(self.env, wrapped_request, ticket) ticket_changed = manipulator.change_status_to(args['simple_status']) if ticket_changed: for attribute_name in ticket._old: args[attribute_name] = ticket[attribute_name]
class TestManipulateTicketStatus(AgiloTestCase): def setUp(self): self.super() self.task = AgiloTicket(self.env, t_type=Type.TASK) # this task is not stored in the db on purpose - so I can check # that no workflow does any permanent damage! del self.task._old[Key.TYPE] req = self.teh.mock_request('foo') self.manipulator = TicketStatusManipulator(self.env, req, self.task) self.assert_equals({}, self.task._old) def _set_status_to(self, status): self.task[Key.STATUS] = status del self.task._old[Key.STATUS] self.assert_equals({}, self.task._old) def test_ignores_workflow_if_no_valid_transition_to_new_was_found(self): self._set_status_to('assigned') self.manipulator.change_status_to('new') self.assert_equals(Status.NEW, self.task[Key.STATUS]) def test_delete_owner_if_new_status_is_new(self): self._set_status_to(Status.ACCEPTED) self.task[Key.OWNER] = 'foo' self.manipulator.change_status_to('new') self.assert_equals(Status.NEW, self.task[Key.STATUS]) self.assert_equals('', self.task[Key.OWNER]) def test_delete_resolution_if_ticket_was_closed_before(self): self._set_status_to(Status.CLOSED) self.task[Key.OWNER] = 'foo' self.task[Key.RESOLUTION] = Status.RES_FIXED self.manipulator.change_status_to('in_progress') self.assert_equals(Status.REOPENED, self.task[Key.STATUS]) self.assert_equals('', self.task[Key.RESOLUTION]) def test_can_ignore_workflow_for_transition_to_closed(self): self.teh.change_workflow_config([('resolve', '* -> in_qa')]) self._set_status_to(Status.ACCEPTED) self.task[Key.OWNER] = 'foo' self.manipulator.change_status_to('closed') self.assert_equals(Status.CLOSED, self.task[Key.STATUS]) self.assert_equals(Status.RES_FIXED, self.task[Key.RESOLUTION]) def test_can_ignore_workflow_for_transition_to_in_progress(self): self.teh.change_workflow_config([('reopen', 'assigned -> new')]) self._set_status_to(Status.CLOSED) self.task[Key.OWNER] = 'bar' self.task[Key.RESOLUTION] = Status.RES_FIXED self.manipulator.change_status_to('in_progress') self.assert_equals(Status.ACCEPTED, self.task[Key.STATUS]) self.assert_equals('', self.task[Key.RESOLUTION]) self.assert_equals('foo', self.task[Key.OWNER]) def test_can_ignore_workflow_for_transition_custom_ticket_status(self): self.teh.change_workflow_config([('fnordify', 'new -> fnord')]) self._set_status_to(Status.NEW) self.manipulator.change_status_to('fnord') self.assert_equals('fnord', self.task[Key.STATUS]) def test_will_choose_assigned_as_default_in_progress_status(self): # not sure in what order the workflows are found, but 'abc' helped trigger this bug # since it's alphabetically smaller than 'accept' self.teh.change_workflow_config([('abc', 'new -> fnord')]) self._set_status_to(Status.NEW) self.manipulator.change_status_to('in_progress') self.assert_equals(Status.ACCEPTED, self.task[Key.STATUS]) def test_can_transition_to_custom_ticket_status(self): self.teh.change_workflow_config([('fnordify', 'new -> fnord')]) self._set_status_to(Status.NEW) self.manipulator.change_status_to('fnord') self.assert_equals('fnord', self.task[Key.STATUS])