ephraimbuddy commented on a change in pull request #17839:
URL: https://github.com/apache/airflow/pull/17839#discussion_r700356792
##########
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##########
@@ -1154,3 +1154,91 @@ def test_should_raises_403_unauthorized(self):
environ_overrides={'REMOTE_USER': "test_view_dags"},
)
assert response.status_code == 403
+
+
+class TestPostSetDagRunState(TestDagRunEndpoint):
+ @parameterized.expand([("failed",), ("success",)])
+ @pytest.fixture(scope="module")
+ def test_should_respond_200(self, state, dag_maker):
+ dag_id = "TEST_DAG_ID"
+ with create_session() as session:
+ dag = DagModel(dag_id=dag_id)
+ dag_run = dag_maker.create_dagrun()
+ session.add(dag)
+ session.add(dag_run)
+
+ request_json = {"state": state}
+
+ response = self.client.post(
+ "api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID_1/state",
+ json=request_json,
+ environ_overrides={"REMOTE_USER": "test"},
+ )
+
+ assert response.status_code == 200
+ assert response.json == {
+ 'conf': {},
+ 'dag_id': 'TEST_DAG_ID',
+ 'dag_run_id': 'TEST_DAG_RUN_ID_1',
Review comment:
```suggestion
'dag_id': dag_id,
'dag_run_id': dag_run_id,
```
##########
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##########
@@ -1154,3 +1154,91 @@ def test_should_raises_403_unauthorized(self):
environ_overrides={'REMOTE_USER': "test_view_dags"},
)
assert response.status_code == 403
+
+
+class TestPostSetDagRunState(TestDagRunEndpoint):
+ @parameterized.expand([("failed",), ("success",)])
+ @pytest.fixture(scope="module")
+ def test_should_respond_200(self, state, dag_maker):
+ dag_id = "TEST_DAG_ID"
+ with create_session() as session:
+ dag = DagModel(dag_id=dag_id)
+ dag_run = dag_maker.create_dagrun()
+ session.add(dag)
+ session.add(dag_run)
+
+ request_json = {"state": state}
+
+ response = self.client.post(
+ "api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID_1/state",
Review comment:
```suggestion
f"api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/state",
```
##########
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##########
@@ -1154,3 +1154,91 @@ def test_should_raises_403_unauthorized(self):
environ_overrides={'REMOTE_USER': "test_view_dags"},
)
assert response.status_code == 403
+
+
+class TestPostSetDagRunState(TestDagRunEndpoint):
+ @parameterized.expand([("failed",), ("success",)])
+ @pytest.fixture(scope="module")
+ def test_should_respond_200(self, state, dag_maker):
+ dag_id = "TEST_DAG_ID"
+ with create_session() as session:
+ dag = DagModel(dag_id=dag_id)
+ dag_run = dag_maker.create_dagrun()
+ session.add(dag)
+ session.add(dag_run)
Review comment:
```suggestion
def test_should_respond_200(self, state, dag_maker):
dag_id = "TEST_DAG_ID"
dag_run_id = 'TEST_DAG_RUN_ID'
with dag_maker(dag_id):
DummyOperator(task_id='task_id')
dag_maker.create_dagrun(run_id=dag_run_id)
```
--
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]