Copilot commented on code in PR #65313:
URL: https://github.com/apache/airflow/pull/65313#discussion_r3097459723
##########
airflow-core/tests/unit/dag_processing/test_processor.py:
##########
@@ -702,6 +699,42 @@ def test_import_error_updates_timestamps(session):
assert stat.import_errors == 1
[email protected]_test
+def test_persist_parsing_result_calls_update_db(session):
+ """persist_parsing_result should delegate to
update_dag_parsing_results_in_db with transformed args."""
+ parsing_result = DagFileParsingResult(
+ fileloc="test.py",
+ serialized_dags=[],
+ import_errors={"dags/broken.py": "SyntaxError"},
+ warnings=[],
+ )
+
+ manager = MagicMock(spec=DagFileProcessorManager)
+ # Call the real method on the mock instance
+ with patch(
+ "airflow.dag_processing.manager.update_dag_parsing_results_in_db",
autospec=True
+ ) as mock_update:
+ DagFileProcessorManager.persist_parsing_result(
+ manager,
+ bundle_name="test-bundle",
+ bundle_version="v1",
+ parsing_result=parsing_result,
+ run_duration=1.5,
+ relative_fileloc="dags/test.py",
+ session=session,
+ )
Review Comment:
This test patches out `update_dag_parsing_results_in_db` and only asserts
argument transformation/forwarding, so it doesn’t need a real DB session.
Consider avoiding `session`/`db_test` here (e.g., pass a `MagicMock` session)
to keep the unit test fast and reduce DB-test surface area.
--
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]