def sync(): """ 发起同步 """ id = request.form.get('id', int) async_result = sync_task.apply_async((id, )) return api_response(code=0, data={'task_id': async_result.id, 'state': async_result.state})
def test_get_state(self): """ 测试获取任务状态 """ task = sync_task.apply_async((1, )) params = { 'id': task.id } result = self.json_get_request('/api/task/state', params=params) self.assertEqual(result['code'], 0) self.assertTrue(result['data'])