Skip to content

Commit

Permalink
fix tests after main rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jedcunningham committed Jan 7, 2025
1 parent 55150a1 commit 677db81
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion airflow/dag_processing/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def run(self):
DagBundlesManager().sync_bundles_to_db()

self.log.info("Getting all DAG bundles")
self._dag_bundles = DagBundlesManager().get_all_dag_bundles()
self._dag_bundles = list(DagBundlesManager().get_all_dag_bundles())

return self._run_parsing_loop()

Expand Down
2 changes: 1 addition & 1 deletion tests/api_connexion/endpoints/test_dag_run_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _create_dag(self, dag_id):
dag = DAG(dag_id=dag_id, schedule=None, params={"validated_number": Param(1, minimum=1, maximum=10)})
DagBundlesManager().sync_bundles_to_db()
self.app.dag_bag.bag_dag(dag)
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)
return dag_instance

def _create_test_dag_run(self, state=DagRunState.RUNNING, extra_dag=False, commit=True, idx_start=1):
Expand Down
2 changes: 1 addition & 1 deletion tests/api_connexion/endpoints/test_extra_link_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def setup_attrs(self, configured_app, session) -> None:
DagBundlesManager().sync_bundles_to_db()
self.app.dag_bag = DagBag(os.devnull, include_examples=False)
self.app.dag_bag.dags = {self.dag.dag_id: self.dag}
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)

triggered_by_kwargs = {"triggered_by": DagRunTriggeredByType.TEST} if AIRFLOW_V_3_0_PLUS else {}
self.dag.create_dagrun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def create_dag_runs_with_mapped_tasks(self, dag_maker, session, dags=None):
DagBundlesManager().sync_bundles_to_db()
self.app.dag_bag = DagBag(os.devnull, include_examples=False)
self.app.dag_bag.dags = {dag_id: dag_maker.dag}
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)
session.flush()

mapped.expand_mapped_task(dr.run_id, session=session)
Expand Down
2 changes: 1 addition & 1 deletion tests/api_connexion/endpoints/test_task_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def setup_dag(self, configured_app):
mapped_dag.dag_id: mapped_dag,
unscheduled_dag.dag_id: unscheduled_dag,
}
dag_bag.sync_to_db("dags_folder", None)
dag_bag.sync_to_db("dags-folder", None)
configured_app.dag_bag = dag_bag # type:ignore

@staticmethod
Expand Down
8 changes: 4 additions & 4 deletions tests/api_connexion/endpoints/test_task_instance_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def test_should_respond_200(self, main_dag, task_instances, request_dag, payload
task_instances=task_instances,
update_extras=False,
)
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)
response = self.client.post(
f"/api/v1/dags/{request_dag}/clearTaskInstances",
environ_overrides={"REMOTE_USER": "test"},
Expand All @@ -1246,7 +1246,7 @@ def test_clear_taskinstance_is_called_with_queued_dr_state(self, mock_clearti, s
self.create_task_instances(session)
dag_id = "example_python_operator"
payload = {"reset_dag_runs": True, "dry_run": False}
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)
response = self.client.post(
f"/api/v1/dags/{dag_id}/clearTaskInstances",
environ_overrides={"REMOTE_USER": "test"},
Expand All @@ -1266,7 +1266,7 @@ def test_clear_taskinstance_is_called_with_invalid_task_ids(self, session):
assert dagrun.state == "running"

payload = {"dry_run": False, "reset_dag_runs": True, "task_ids": [""]}
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)
response = self.client.post(
f"/api/v1/dags/{dag_id}/clearTaskInstances",
environ_overrides={"REMOTE_USER": "test"},
Expand Down Expand Up @@ -1693,7 +1693,7 @@ def test_should_raise_400_for_naive_and_bad_datetime(self, payload, expected, se
task_instances=task_instances,
update_extras=False,
)
self.app.dag_bag.sync_to_db("dags_folder", None)
self.app.dag_bag.sync_to_db("dags-folder", None)
response = self.client.post(
"/api/v1/dags/example_python_operator/clearTaskInstances",
environ_overrides={"REMOTE_USER": "test"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setup(self, test_client, session=None) -> None:
dag_bag = DagBag(os.devnull, include_examples=False)
dag_bag.dags = {self.dag.dag_id: self.dag}
test_client.app.state.dag_bag = dag_bag
dag_bag.sync_to_db("dags_folder", None)
dag_bag.sync_to_db("dags-folder", None)

triggered_by_kwargs = {"triggered_by": DagRunTriggeredByType.TEST}

Expand Down
18 changes: 9 additions & 9 deletions tests/api_fastapi/core_api/routes/public/test_task_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def create_dag_runs_with_mapped_tasks(self, dag_maker, session, dags=None):
DagBundlesManager().sync_bundles_to_db()
dagbag = DagBag(os.devnull, include_examples=False)
dagbag.dags = {dag_id: dag_maker.dag}
dagbag.sync_to_db("dags_folder", None)
dagbag.sync_to_db("dags-folder", None)
session.flush()

mapped.expand_mapped_task(dr.run_id, session=session)
Expand Down Expand Up @@ -1859,7 +1859,7 @@ def test_should_respond_200(
task_instances=task_instances,
update_extras=False,
)
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{request_dag}/clearTaskInstances",
json=payload,
Expand All @@ -1873,7 +1873,7 @@ def test_clear_taskinstance_is_called_with_queued_dr_state(self, mock_clearti, t
self.create_task_instances(session)
dag_id = "example_python_operator"
payload = {"reset_dag_runs": True, "dry_run": False}
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{dag_id}/clearTaskInstances",
json=payload,
Expand All @@ -1893,7 +1893,7 @@ def test_clear_taskinstance_is_called_with_invalid_task_ids(self, test_client, s
assert dagrun.state == "running"

payload = {"dry_run": False, "reset_dag_runs": True, "task_ids": [""]}
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{dag_id}/clearTaskInstances",
json=payload,
Expand Down Expand Up @@ -1943,7 +1943,7 @@ def test_should_respond_200_with_reset_dag_run(self, test_client, session):
update_extras=False,
dag_run_state=DagRunState.FAILED,
)
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{dag_id}/clearTaskInstances",
json=payload,
Expand Down Expand Up @@ -2028,7 +2028,7 @@ def test_should_respond_200_with_dag_run_id(self, test_client, session):
update_extras=False,
dag_run_state=State.FAILED,
)
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{dag_id}/clearTaskInstances",
json=payload,
Expand Down Expand Up @@ -2084,7 +2084,7 @@ def test_should_respond_200_with_include_past(self, test_client, session):
update_extras=False,
dag_run_state=State.FAILED,
)
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{dag_id}/clearTaskInstances",
json=payload,
Expand Down Expand Up @@ -2166,7 +2166,7 @@ def test_should_respond_200_with_include_future(self, test_client, session):
update_extras=False,
dag_run_state=State.FAILED,
)
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
f"/public/dags/{dag_id}/clearTaskInstances",
json=payload,
Expand Down Expand Up @@ -2314,7 +2314,7 @@ def test_should_raise_400_for_naive_and_bad_datetime(self, test_client, session,
task_instances=task_instances,
update_extras=False,
)
self.dagbag.sync_to_db("dags_folder", None)
self.dagbag.sync_to_db("dags-folder", None)
response = test_client.post(
"/public/dags/example_python_operator/clearTaskInstances",
json=payload,
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/commands/remote_commands/test_task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_cli_test_different_path(self, session, tmp_path):
with conf_vars({("core", "dags_folder"): orig_dags_folder.as_posix()}):
dagbag = DagBag(include_examples=False)
dag = dagbag.get_dag("test_dags_folder")
dagbag.sync_to_db("dags_folder", None, session=session)
dagbag.sync_to_db("dags-folder", None, session=session)

logical_date = pendulum.now("UTC")
data_interval = dag.timetable.infer_manual_data_interval(run_after=logical_date)
Expand Down
15 changes: 8 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ def configure_testing_dag_bundle():

@contextmanager
def _config_bundle(path_to_parse: Path | str):
bundle_config = {
"classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
"kwargs": {"local_folder": str(path_to_parse), "refresh_interval": 30},
}
with conf_vars(
{("dag_bundles", "testing"): json.dumps(bundle_config), ("dag_bundles", "dags_folder"): ""}
):
bundle_config = [
{
"name": "testing",
"classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
"kwargs": {"local_folder": str(path_to_parse), "refresh_interval": 30},
}
]
with conf_vars({("dag_bundles", "backends"): json.dumps(bundle_config)}):
yield

return _config_bundle
Expand Down
4 changes: 2 additions & 2 deletions tests_common/test_utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _bootstrap_dagbag():
dagbag = DagBag()
# Save DAGs in the ORM
if AIRFLOW_V_3_0_PLUS:
dagbag.sync_to_db(bundle_name="dags_folder", bundle_version=None, session=session)
dagbag.sync_to_db(bundle_name="dags-folder", bundle_version=None, session=session)
else:
dagbag.sync_to_db(session=session)

Expand Down Expand Up @@ -120,7 +120,7 @@ def parse_and_sync_to_db(folder: Path | str, include_examples: bool = False):

dagbag = DagBag(dag_folder=folder, include_examples=include_examples)
if AIRFLOW_V_3_0_PLUS:
dagbag.sync_to_db("dags_folder", None, session)
dagbag.sync_to_db("dags-folder", None, session)
else:
dagbag.sync_to_db(session=session) # type: ignore[call-arg]
session.commit()
Expand Down

0 comments on commit 677db81

Please sign in to comment.