diff --git a/tests/www/views/test_views_acl.py b/tests/www/views/test_views_acl.py index 139644f67a6da..7b60a2c11ecad 100644 --- a/tests/www/views/test_views_acl.py +++ b/tests/www/views/test_views_acl.py @@ -136,13 +136,13 @@ def acl_app(app): @pytest.fixture(scope="module") -def reset_dagruns(): +def _reset_dagruns(): """Clean up stray garbage from other tests.""" clear_db_runs() @pytest.fixture(autouse=True) -def init_dagruns(acl_app, reset_dagruns): +def _init_dagruns(acl_app, _reset_dagruns): triggered_by_kwargs = {"triggered_by": DagRunTriggeredByType.TEST} if AIRFLOW_V_3_0_PLUS else {} acl_app.dag_bag.get_dag("example_bash_operator").create_dagrun( run_id=DEFAULT_RUN_ID, @@ -322,7 +322,7 @@ def test_dag_autocomplete_dag_display_name(client_all_dags): @pytest.fixture -def setup_paused_dag(): +def _setup_paused_dag(): """Pause a DAG so we can test filtering.""" dag_to_pause = "example_branch_operator" with create_session() as session: @@ -339,7 +339,7 @@ def setup_paused_dag(): ("paused", "example_branch_operator", "example_branch_labels"), ], ) -@pytest.mark.usefixtures("setup_paused_dag") +@pytest.mark.usefixtures("_setup_paused_dag") def test_dag_autocomplete_status(client_all_dags, status, expected, unexpected): with client_all_dags.session_transaction() as flask_session: flask_session[FILTER_STATUS_COOKIE] = status diff --git a/tests/www/views/test_views_cluster_activity.py b/tests/www/views/test_views_cluster_activity.py index cdcebc1c8cf34..543d563e8da03 100644 --- a/tests/www/views/test_views_cluster_activity.py +++ b/tests/www/views/test_views_cluster_activity.py @@ -39,20 +39,20 @@ def examples_dag_bag(): @pytest.fixture(autouse=True) -def clean(): +def _clean(): clear_db_runs() yield clear_db_runs() -# freeze time fixture so that it is applied before `make_dag_runs` is! +# freeze time fixture so that it is applied before `_make_dag_runs` is! @pytest.fixture -def freeze_time_for_dagruns(time_machine): +def _freeze_time_for_dagruns(time_machine): time_machine.move_to("2023-05-02T00:00:00+00:00", tick=False) @pytest.fixture -def make_dag_runs(dag_maker, session, time_machine): +def _make_dag_runs(dag_maker, session, time_machine): with dag_maker( dag_id="test_dag_id", serialized=True, @@ -99,7 +99,7 @@ def make_dag_runs(dag_maker, session, time_machine): session.flush() -@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_dag_runs") +@pytest.mark.usefixtures("_freeze_time_for_dagruns", "_make_dag_runs") def test_historical_metrics_data(admin_client, session, time_machine): resp = admin_client.get( "/object/historical_metrics_data?start_date=2023-01-01T00:00&end_date=2023-08-02T00:00", @@ -127,7 +127,7 @@ def test_historical_metrics_data(admin_client, session, time_machine): } -@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_dag_runs") +@pytest.mark.usefixtures("_freeze_time_for_dagruns", "_make_dag_runs") def test_historical_metrics_data_date_filters(admin_client, session): resp = admin_client.get( "/object/historical_metrics_data?start_date=2023-02-02T00:00&end_date=2023-06-02T00:00", diff --git a/tests/www/views/test_views_connection.py b/tests/www/views/test_views_connection.py index a209cdfc2be8a..7530a1f677f9b 100644 --- a/tests/www/views/test_views_connection.py +++ b/tests/www/views/test_views_connection.py @@ -47,7 +47,7 @@ def conn_with_extra() -> dict[str, Any]: @pytest.fixture(autouse=True) -def clear_connections(): +def _clear_connections(): with create_session() as session: session.query(Connection).delete() diff --git a/tests/www/views/test_views_dagrun.py b/tests/www/views/test_views_dagrun.py index d95955246ac78..9e45464c28aa1 100644 --- a/tests/www/views/test_views_dagrun.py +++ b/tests/www/views/test_views_dagrun.py @@ -93,7 +93,7 @@ def client_dr_without_dag_run_create(app): @pytest.fixture(scope="module", autouse=True) -def init_blank_dagrun(): +def _init_blank_dagrun(): """Make sure there are no runs before we test anything. This really shouldn't be needed, but tests elsewhere leave the db dirty. @@ -104,7 +104,7 @@ def init_blank_dagrun(): @pytest.fixture(autouse=True) -def reset_dagrun(): +def _reset_dagrun(): yield with create_session() as session: session.query(DagRun).delete() diff --git a/tests/www/views/test_views_dataset.py b/tests/www/views/test_views_dataset.py index 3d3351bb6493a..3db16a996862e 100644 --- a/tests/www/views/test_views_dataset.py +++ b/tests/www/views/test_views_dataset.py @@ -32,7 +32,7 @@ class TestDatasetEndpoint: @pytest.fixture(autouse=True) - def cleanup(self): + def _cleanup(self): clear_db_assets() yield clear_db_assets() diff --git a/tests/www/views/test_views_decorators.py b/tests/www/views/test_views_decorators.py index e1bc1db0efc48..86bce2f3bbbc2 100644 --- a/tests/www/views/test_views_decorators.py +++ b/tests/www/views/test_views_decorators.py @@ -78,7 +78,7 @@ def dagruns(bash_dag, xcom_dag): @pytest.fixture(autouse=True) -def clean_db(): +def _clean_db(): clear_db_variables() yield clear_db_variables() diff --git a/tests/www/views/test_views_extra_links.py b/tests/www/views/test_views_extra_links.py index 55b2424f3a9f0..4fb0d2d40b017 100644 --- a/tests/www/views/test_views_extra_links.py +++ b/tests/www/views/test_views_extra_links.py @@ -101,7 +101,7 @@ def dag_run(create_dag_run, session): @pytest.fixture(scope="module", autouse=True) -def patched_app(app, dag): +def _patched_app(app, dag): with mock.patch.object(app, "dag_bag") as mock_dag_bag: mock_dag_bag.get_dag.return_value = dag yield @@ -123,7 +123,7 @@ def task_3(dag): @pytest.fixture(scope="module", autouse=True) -def init_blank_task_instances(): +def _init_blank_task_instances(): """Make sure there are no runs before we test anything. This really shouldn't be needed, but tests elsewhere leave the db dirty. @@ -132,7 +132,7 @@ def init_blank_task_instances(): @pytest.fixture(autouse=True) -def reset_task_instances(): +def _reset_task_instances(): yield clear_db_runs() diff --git a/tests/www/views/test_views_grid.py b/tests/www/views/test_views_grid.py index b4dd6f6082e57..8d5e4e22e04b8 100644 --- a/tests/www/views/test_views_grid.py +++ b/tests/www/views/test_views_grid.py @@ -54,7 +54,7 @@ def examples_dag_bag(): @pytest.fixture(autouse=True) -def clean(): +def _clean(): clear_db_runs() clear_db_assets() yield @@ -187,11 +187,11 @@ def test_grid_data_filtered_on_run_type_and_run_state(admin_client, dag_with_run # Create this as a fixture so that it is applied before the `dag_with_runs` fixture is! @pytest.fixture -def freeze_time_for_dagruns(time_machine): +def _freeze_time_for_dagruns(time_machine): time_machine.move_to("2022-01-02T00:00:00+00:00", tick=False) -@pytest.mark.usefixtures("freeze_time_for_dagruns") +@pytest.mark.usefixtures("_freeze_time_for_dagruns") def test_one_run(admin_client, dag_with_runs: list[DagRun], session): """ Test a DAG with complex interaction of states: diff --git a/tests/www/views/test_views_home.py b/tests/www/views/test_views_home.py index 44dda24feecbc..6a5bf3c4ad531 100644 --- a/tests/www/views/test_views_home.py +++ b/tests/www/views/test_views_home.py @@ -42,7 +42,7 @@ def clean_db(): @pytest.fixture(autouse=True) -def setup(): +def _setup(): clean_db() yield clean_db() @@ -72,7 +72,7 @@ def test_home(capture_templates, admin_client): @mock.patch("airflow.www.views.AirflowBaseView.render_template") -def test_home_dags_count(render_template_mock, admin_client, working_dags, session): +def test_home_dags_count(render_template_mock, admin_client, _working_dags, session): from sqlalchemy import update from airflow.models.dag import DagModel @@ -204,7 +204,7 @@ def _process_file(file_path): @pytest.fixture -def working_dags(tmp_path): +def _working_dags(tmp_path): dag_contents_template = "from airflow import DAG\ndag = DAG('{}', schedule=None, tags=['{}'])" for dag_id, tag in zip(TEST_FILTER_DAG_IDS, TEST_TAGS): path = tmp_path / f"{dag_id}.py" @@ -213,7 +213,7 @@ def working_dags(tmp_path): @pytest.fixture -def working_dags_with_read_perm(tmp_path): +def _working_dags_with_read_perm(tmp_path): dag_contents_template = "from airflow import DAG\ndag = DAG('{}', schedule=None, tags=['{}'])" dag_contents_template_with_read_perm = ( "from airflow import DAG\ndag = DAG('{}', schedule=None, tags=['{}'], " @@ -229,7 +229,7 @@ def working_dags_with_read_perm(tmp_path): @pytest.fixture -def working_dags_with_edit_perm(tmp_path): +def _working_dags_with_edit_perm(tmp_path): dag_contents_template = "from airflow import DAG\ndag = DAG('{}', schedule=None, tags=['{}'])" dag_contents_template_with_read_perm = ( "from airflow import DAG\ndag = DAG('{}', schedule=None, tags=['{}'], " @@ -245,7 +245,7 @@ def working_dags_with_edit_perm(tmp_path): @pytest.fixture -def broken_dags(tmp_path, working_dags): +def _broken_dags(tmp_path, _working_dags): for dag_id in TEST_FILTER_DAG_IDS: path = tmp_path / f"{dag_id}.py" path.write_text("airflow DAG") @@ -253,7 +253,7 @@ def broken_dags(tmp_path, working_dags): @pytest.fixture -def broken_dags_with_read_perm(tmp_path, working_dags_with_read_perm): +def _broken_dags_with_read_perm(tmp_path, _working_dags_with_read_perm): for dag_id in TEST_FILTER_DAG_IDS: path = tmp_path / f"{dag_id}.py" path.write_text("airflow DAG") @@ -261,7 +261,7 @@ def broken_dags_with_read_perm(tmp_path, working_dags_with_read_perm): @pytest.fixture -def broken_dags_after_working(tmp_path): +def _broken_dags_after_working(tmp_path): # First create and process a DAG file that works path = tmp_path / "all_in_one.py" contents = "from airflow import DAG\n" @@ -275,7 +275,7 @@ def broken_dags_after_working(tmp_path): _process_file(path) -def test_home_filter_tags(working_dags, admin_client): +def test_home_filter_tags(_working_dags, admin_client): with admin_client: admin_client.get("home?tags=example&tags=data", follow_redirects=True) assert "example,data" == flask.session[FILTER_TAGS_COOKIE] @@ -284,7 +284,7 @@ def test_home_filter_tags(working_dags, admin_client): assert flask.session[FILTER_TAGS_COOKIE] is None -def test_home_importerrors(broken_dags, user_client): +def test_home_importerrors(_broken_dags, user_client): # Users with "can read on DAGs" gets all DAG import errors resp = user_client.get("home", follow_redirects=True) check_content_in_response("Import Errors", resp) @@ -292,7 +292,7 @@ def test_home_importerrors(broken_dags, user_client): check_content_in_response(f"/{dag_id}.py", resp) -def test_home_no_importerrors_perm(broken_dags, client_no_importerror): +def test_home_no_importerrors_perm(_broken_dags, client_no_importerror): # Users without "can read on import errors" don't see any import errors resp = client_no_importerror.get("home", follow_redirects=True) check_content_not_in_response("Import Errors", resp) @@ -310,7 +310,7 @@ def test_home_no_importerrors_perm(broken_dags, client_no_importerror): "home?lastrun=all_states", ], ) -def test_home_importerrors_filtered_singledag_user(broken_dags_with_read_perm, client_single_dag, page): +def test_home_importerrors_filtered_singledag_user(_broken_dags_with_read_perm, client_single_dag, page): # Users that can only see certain DAGs get a filtered list of import errors resp = client_single_dag.get(page, follow_redirects=True) check_content_in_response("Import Errors", resp) @@ -322,7 +322,7 @@ def test_home_importerrors_filtered_singledag_user(broken_dags_with_read_perm, c check_content_not_in_response(f"/{dag_id}.py", resp) -def test_home_importerrors_missing_read_on_all_dags_in_file(broken_dags_after_working, client_single_dag): +def test_home_importerrors_missing_read_on_all_dags_in_file(_broken_dags_after_working, client_single_dag): # If a user doesn't have READ on all DAGs in a file, that files traceback is redacted resp = client_single_dag.get("home", follow_redirects=True) check_content_in_response("Import Errors", resp) @@ -333,14 +333,14 @@ def test_home_importerrors_missing_read_on_all_dags_in_file(broken_dags_after_wo check_content_in_response("REDACTED", resp) -def test_home_dag_list(working_dags, user_client): +def test_home_dag_list(_working_dags, user_client): # Users with "can read on DAGs" gets all DAGs resp = user_client.get("home", follow_redirects=True) for dag_id in TEST_FILTER_DAG_IDS: check_content_in_response(f"dag_id={dag_id}", resp) -def test_home_dag_list_filtered_singledag_user(working_dags_with_read_perm, client_single_dag): +def test_home_dag_list_filtered_singledag_user(_working_dags_with_read_perm, client_single_dag): # Users that can only see certain DAGs get a filtered list resp = client_single_dag.get("home", follow_redirects=True) # They can see the first DAG @@ -350,7 +350,7 @@ def test_home_dag_list_filtered_singledag_user(working_dags_with_read_perm, clie check_content_not_in_response(f"dag_id={dag_id}", resp) -def test_home_dag_list_search(working_dags, user_client): +def test_home_dag_list_search(_working_dags, user_client): resp = user_client.get("home?search=filter_test", follow_redirects=True) check_content_in_response("dag_id=filter_test_1", resp) check_content_in_response("dag_id=filter_test_2", resp) @@ -358,7 +358,7 @@ def test_home_dag_list_search(working_dags, user_client): check_content_not_in_response("dag_id=a_first_dag_id_asc", resp) -def test_home_dag_edit_permissions(capture_templates, working_dags_with_edit_perm, client_single_dag_edit): +def test_home_dag_edit_permissions(capture_templates, _working_dags_with_edit_perm, client_single_dag_edit): with capture_templates() as templates: client_single_dag_edit.get("home", follow_redirects=True) @@ -446,7 +446,7 @@ def test_dashboard_flash_messages_type(user_client): ], ids=["no_order_provided", "ascending_order_on_dag_id", "descending_order_on_dag_id"], ) -def test_sorting_home_view(url, lower_key, greater_key, user_client, working_dags): +def test_sorting_home_view(url, lower_key, greater_key, user_client, _working_dags): resp = user_client.get(url, follow_redirects=True) resp_html = resp.data.decode("utf-8") lower_index = resp_html.find(lower_key) @@ -489,7 +489,7 @@ def test_analytics_pixel(user_client, is_enabled, should_have_pixel): ], ) def test_filter_cookie_eval( - working_dags, + _working_dags, admin_client, url, filter_tags_cookie_val, diff --git a/tests/www/views/test_views_log.py b/tests/www/views/test_views_log.py index f59fe7418f395..72e282c7b3f8c 100644 --- a/tests/www/views/test_views_log.py +++ b/tests/www/views/test_views_log.py @@ -117,7 +117,7 @@ def factory(): @pytest.fixture(autouse=True) -def reset_modules_after_every_test(backup_modules): +def _reset_modules_after_every_test(backup_modules): yield # Remove any new modules imported during the test run. # This lets us import the same source files for more than one test. diff --git a/tests/www/views/test_views_pool.py b/tests/www/views/test_views_pool.py index 3fcacbbbf8bed..020c5353a5f34 100644 --- a/tests/www/views/test_views_pool.py +++ b/tests/www/views/test_views_pool.py @@ -36,7 +36,7 @@ @pytest.fixture(autouse=True) -def clear_pools(): +def _clear_pools(): with create_session() as session: session.query(Pool).delete() diff --git a/tests/www/views/test_views_rendered.py b/tests/www/views/test_views_rendered.py index 2d1754af29f65..87e693d5400ab 100644 --- a/tests/www/views/test_views_rendered.py +++ b/tests/www/views/test_views_rendered.py @@ -119,7 +119,7 @@ def task_secret(dag): @pytest.fixture(scope="module", autouse=True) -def init_blank_db(): +def _init_blank_db(): """Make sure there are no runs before we test anything. This really shouldn't be needed, but tests elsewhere leave the db dirty. @@ -130,7 +130,7 @@ def init_blank_db(): @pytest.fixture(autouse=True) -def reset_db(dag, task1, task2, task3, task4, task_secret): +def _reset_db(dag, task1, task2, task3, task4, task_secret): yield clear_db_dags() clear_db_runs()