mik-laj commented on pull request #19487:
URL: https://github.com/apache/airflow/pull/19487#issuecomment-968362025


   I wrote the following test cases and it works:
   ```python
       @provide_session
       def test_should_respond_200_for_none_state_filter(self, session):
           dag_id = 'example_python_operator'
           dag = self.dagbag.get_dag(dag_id)
           run_id = "TEST_DAG_RUN_ID"
           dr = DagRun(
               run_id=run_id,
               dag_id=dag_id,
               run_type=DagRunType.MANUAL,
           )
           session.add(dr)
           session.commit()
           ti = TaskInstance(task=dag.tasks[0], run_id=run_id, state=None)
           ti.dag_run = dr
           session.add(ti)
           session.commit()
           response = self.client.get(
               f"/api/v1/dags/{dag_id}/dagRuns/~/taskInstances?state=none",
               environ_overrides={"REMOTE_USER": "test"},
           )
           assert 1 == session.query(TaskInstance).count()
           assert 1 == session.query(DagRun).count()
           assert response.status_code == 200
           assert [('example_python_operator', 'TEST_DAG_RUN_ID', 
'print_the_context', None)] == [
               (d['dag_id'], d['dag_run_id'], d['task_id'], d['state']) for d 
in response.json['task_instances']
           ]
           response = self.client.get(
               f"/api/v1/dags/{dag_id}/dagRuns/~/taskInstances?state=running",
               environ_overrides={"REMOTE_USER": "test"},
           )
           assert 200 == response.status_code
           assert 0 == len(response.json['task_instances'])
   ```
   
   However, I ran into another problem. I could not run the tests as long as 
the `execution_date` field was defined in TaskInstanceSchema.
   Have you encountered this problem?
   ```
   $ pytest tests/api_connexion/endpoints/test_task_instance_endpoint.py -k 
test_should_respond_200_for_none_state_filter -s
   ....
   E           sqlalchemy.exc.InvalidRequestError: Mapper 'mapped class 
TaskInstance->task_instance' has no property 'execution_date'
   
   /usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py:182: 
InvalidRequestError
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to