Beispiel #1
0
 def test_find_archived_call_by_task_group_id(self):
     call_request, call_report = self._generate_request_and_report()
     call_request.group_id = call_report.call_request_group_id = '123'
     history.archive_call(call_request, call_report)
     archived_calls = history.find_archived_calls(
         call_request_group_id='123')
     self.assertEqual(archived_calls.count(), 1)
    def test_reaper(self):
        call_request, call_report = self._generate_request_and_report()
        history.archive_call(call_report, call_request)
        self.assertEqual(self.archived_call_collection.find().count(), 1)

        history.purge_archived_tasks()
        self.assertEqual(self.archived_call_collection.find().count(), 0)
Beispiel #3
0
 def _complete(self, state=dispatch_constants.CALL_FINISHED_STATE):
     """
     Cleanup and state finalization for call on either success or failure.
     """
     assert state in dispatch_constants.CALL_COMPLETE_STATES
     self.call_report.finish_time = datetime.datetime.now(dateutils.utc_tz())
     self.call_request_exit_state = state
     self._call_complete_callback()
     # don't set the state to complete in the report until the task is actually complete
     self.call_report.state = state
     self.call_life_cycle_callbacks(dispatch_constants.CALL_COMPLETE_LIFE_CYCLE_CALLBACK)
     if not self.call_request.archive:
         return
     # archive the completed call
     dispatch_history.archive_call(self.call_request, self.call_report)
Beispiel #4
0
 def _complete(self, state=dispatch_constants.CALL_FINISHED_STATE):
     """
     Cleanup and state finalization for call on either success or failure.
     """
     assert state in dispatch_constants.CALL_COMPLETE_STATES
     self.call_report.finish_time = datetime.datetime.now(dateutils.utc_tz())
     # FIXME we'll need to pass the state along with the task into the
     # complete callback for conditional blocking tasks (conditional on the
     # complete state), however this causes a race condition between when the
     # task is marked as complete (by setting its state) and when it's done
     # with that task queue
     self._call_complete_callback()
     # don't set the state to complete until the task is actually complete
     self.call_report.state = state
     self.call_life_cycle_callbacks(dispatch_constants.CALL_COMPLETE_LIFE_CYCLE_CALLBACK)
     if not self.call_request.archive:
         return
     # archive the completed call
     dispatch_history.archive_call(self.call_request, self.call_report)
Beispiel #5
0
    def _complete(self, state=dispatch_constants.CALL_FINISHED_STATE):
        """
        Cleanup and state finalization for call on either success or failure.
        """
        assert state in dispatch_constants.CALL_COMPLETE_STATES

        self.call_report.finish_time = datetime.datetime.now(
            dateutils.utc_tz())
        self.call_request_exit_state = state

        self._call_complete_callback()

        # don't set the state to complete in the report until the task is actually complete
        self.call_report.state = state

        self.call_life_cycle_callbacks(
            dispatch_constants.CALL_COMPLETE_LIFE_CYCLE_CALLBACK)
        if not self.call_request.archive:
            return

        # archive the completed call
        dispatch_history.archive_call(self.call_request, self.call_report)
 def _test_find_archived_call_by_task_group_id(self):
     call_request, call_report = self._generate_request_and_report()
     call_report.task_group_id = "456"
     history.archive_call(call_report, call_request)
     archived_calls = history.find_archived_calls(task_group_id="456")
     self.assertEqual(archived_calls.count(), 1)
Beispiel #7
0
 def test_create_archived_call(self):
     call_request, call_report = self._generate_request_and_report()
     history.archive_call(call_request, call_report)
     self.assertEqual(self.archived_call_collection.find().count(), 1)