def test_delay_or_eager_runs(self, mock_calculate_result): with eager_tasks(self.app): async_task = self.task.delay_or_eager(result=1) self.assertEqual(async_task.status, states.SUCCESS) self.assertEqual(async_task.result, 1) self.assertEqual(mock_calculate_result.call_count, 1)
def test_starts_with_progress_state(self): # The state has already been set to PROGRESS before `calculate_result` # starts with eager_tasks(self.app): with mock.patch.object( self.task, 'calculate_result', autospec=True, side_effect=task_status_is_progress, ): async_task = self.task.delay(count_to=2) # And the state should still be set to SUCCESS in the end self.assertEqual(async_task.status, SUCCESS)
def test_sanity(self): # The task actually runs with eager_tasks(self.app): async_task = self.task.delay(result=1) self.assertEqual(async_task.status, states.SUCCESS) self.assertEqual(async_task.result, 1)
def test_sanity(self): # The task actually runs with eager_tasks(self.app): async_task = self.task.delay(count_to=2) self.assertEqual(async_task.status, SUCCESS) self.assertEqual(async_task.result, 2)