Bugfix: Allow getting details of a DAG with null start_date (REST API) (#13959)

This commit is contained in:
Ephraim Anierobi 2021-01-29 19:45:41 +01:00 коммит произвёл GitHub
Родитель 047397c232
Коммит fdb83c7439
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 41 добавлений и 1 удалений

Просмотреть файл

@ -1937,6 +1937,7 @@ components:
type: string
format: 'date-time'
readOnly: true
nullable: true
dag_run_timeout:
nullable: true
$ref: '#/components/schemas/TimeDelta'

Просмотреть файл

@ -42,6 +42,7 @@ class TestDagEndpoint(unittest.TestCase):
dag_id = "test_dag"
task_id = "op1"
dag2_id = "test_dag2"
dag3_id = "test_dag3"
@staticmethod
def clean_db():
@ -80,10 +81,16 @@ class TestDagEndpoint(unittest.TestCase):
with DAG(cls.dag2_id, start_date=datetime(2020, 6, 15)) as dag2: # no doc_md
DummyOperator(task_id=cls.task_id)
with DAG(cls.dag3_id) as dag3: # DAG start_date set to None
DummyOperator(task_id=cls.task_id, start_date=datetime(2019, 6, 12))
cls.dag = dag # type:ignore
cls.dag2 = dag2 # type: ignore
cls.dag3 = dag3 # tupe: ignore
dag_bag = DagBag(os.devnull, include_examples=False)
dag_bag.dags = {dag.dag_id: dag, dag2.dag_id: dag2}
dag_bag.dags = {dag.dag_id: dag, dag2.dag_id: dag2, dag3.dag_id: dag3}
cls.app.dag_bag = dag_bag # type:ignore
@classmethod
@ -251,6 +258,38 @@ class TestGetDagDetails(TestDagEndpoint):
}
assert response.json == expected
def test_should_response_200_for_null_start_date(self):
response = self.client.get(
f"/api/v1/dags/{self.dag3_id}/details", environ_overrides={'REMOTE_USER': "test"}
)
assert response.status_code == 200
expected = {
"catchup": True,
"concurrency": 16,
"dag_id": "test_dag3",
"dag_run_timeout": None,
"default_view": "tree",
"description": None,
"doc_md": None,
"fileloc": __file__,
"file_token": FILE_TOKEN,
"is_paused": None,
"is_subdag": False,
"orientation": "LR",
"owners": [],
"params": {},
"schedule_interval": {
"__type": "TimeDelta",
"days": 1,
"microseconds": 0,
"seconds": 0,
},
"start_date": None,
"tags": None,
"timezone": "Timezone('UTC')",
}
assert response.json == expected
def test_should_respond_200_serialized(self):
# Create empty app with empty dagbag to check if DAG is read from db
with conf_vars({("api", "auth_backend"): "tests.test_utils.remote_user_api_auth_backend"}):