ashb commented on a change in pull request #17556:
URL: https://github.com/apache/airflow/pull/17556#discussion_r691163847
##########
File path: tests/models/test_dagbag.py
##########
@@ -170,20 +172,20 @@ def my_flow():
assert dagbag.import_errors[tf_2.name].startswith("Ignoring DAG")
assert dagbag.dags == dags_in_bag # Should not change.
- def test_zip_skip_log(self):
+ def test_zip_skip_log(self, caplog):
"""
test the loading of a DAG from within a zip file that skips another
file because
it doesn't have "airflow" and "DAG"
"""
- with self.assertLogs() as cm:
- test_zip_path = os.path.join(TEST_DAGS_FOLDER, "test_zip.zip")
- dagbag = models.DagBag(dag_folder=test_zip_path,
include_examples=False)
+ caplog.set_level(logging.INFO)
+ test_zip_path = os.path.join(TEST_DAGS_FOLDER, "test_zip.zip")
+ dagbag = models.DagBag(dag_folder=test_zip_path,
include_examples=False)
- assert dagbag.has_logged
- assert (
- f'INFO:airflow.models.dagbag.DagBag:File
{test_zip_path}:file_no_airflow_dag.py '
- 'assumed to contain no DAGs. Skipping.' in cm.output
- )
+ assert dagbag.has_logged
+ assert (
+ f'File {test_zip_path}:file_no_airflow_dag.py '
+ 'assumed to contain no DAGs. Skipping.' in caplog.text
+ )
Review comment:
Yeah, caplog behaves slightly differently. This test is good enough.
##########
File path: tests/models/test_dagbag.py
##########
@@ -312,22 +314,20 @@ def process_file(self, filepath, only_if_updated=True,
safe_mode=True):
assert dag_id == dag.dag_id
assert 2 == dagbag.process_file_calls
- def test_dag_removed_if_serialized_dag_is_removed(self):
+ def test_dag_removed_if_serialized_dag_is_removed(self, dag_maker):
"""
Test that if a DAG does not exist in serialized_dag table (as the DAG
file was removed),
remove dags from the DagBag
"""
from airflow.operators.dummy import DummyOperator
- dag = models.DAG(
+ with dag_maker(
dag_id="test_dag_removed_if_serialized_dag_is_removed",
schedule_interval=None,
start_date=tz.datetime(2021, 10, 12),
- )
-
- with dag:
+ ) as dag:
DummyOperator(task_id="task_1")
-
+ dag_maker.create_dagrun()
Review comment:
We probably don't need/want this on e-- dagbag doesn't care about runs
does it?
--
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]