Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ repos:
^airflow-ctl.*\.py$|
^airflow-core/src/airflow/models/.*\.py$|
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py$|
^airflow-core/tests/unit/utils/test_state.py$|
^airflow-core/tests/unit/utils/test_db_cleanup.py$|
^dev/airflow_perf/scheduler_dag_execution_timing.py$|
^providers/openlineage/.*\.py$|
Expand Down
11 changes: 4 additions & 7 deletions airflow-core/tests/unit/utils/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from datetime import timedelta

import pytest
from sqlalchemy import select

from airflow.models.dagrun import DagRun
from airflow.sdk import DAG
Expand Down Expand Up @@ -58,22 +59,18 @@ def test_dagrun_state_enum_escape(testing_dag_bundle):
triggered_by=DagRunTriggeredByType.TEST,
)

query = session.query(
DagRun.dag_id,
DagRun.state,
DagRun.run_type,
).filter(
stmt = select(DagRun.dag_id, DagRun.state, DagRun.run_type).where(
DagRun.dag_id == dag.dag_id,
# make sure enum value can be used in filter queries
DagRun.state == DagRunState.QUEUED,
)
assert str(query.statement.compile(compile_kwargs={"literal_binds": True})) == (
assert str(stmt.compile(compile_kwargs={"literal_binds": True})) == (
"SELECT dag_run.dag_id, dag_run.state, dag_run.run_type \n"
"FROM dag_run \n"
"WHERE dag_run.dag_id = 'test_dagrun_state_enum_escape' AND dag_run.state = 'queued'"
)

rows = query.all()
rows = session.execute(stmt).all()
assert len(rows) == 1
assert rows[0].dag_id == dag.dag_id
# make sure value in db is stored as `queued`, not `DagRunType.QUEUED`
Expand Down
Loading