From 8465c5bfdc8c2ff810e208c658eda875e8ff0871 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Mon, 30 Oct 2023 08:15:17 +0100 Subject: [PATCH] Add pytest db_test markers to our tests This PR is separated out from #35160 in order to make the big refactor and splitting out our test harness to DB and Non-DB tests far more easy to review. This change contains purely adding db_tests markers to the tests that need them, and as such it requires very litte effort to review. Once this one is merged hoever, the #35160 will become way smaller in terms of number of files to review, which will make it far easier to review using GitHub Interface. --- tests/always/test_connection.py | 2 ++ tests/always/test_example_dags.py | 2 ++ tests/always/test_secrets.py | 3 +++ tests/always/test_secrets_backends.py | 2 ++ .../endpoints/test_config_endpoint.py | 3 +++ .../endpoints/test_connection_endpoint.py | 2 ++ .../endpoints/test_dag_endpoint.py | 2 ++ .../endpoints/test_dag_run_endpoint.py | 2 ++ .../endpoints/test_dag_source_endpoint.py | 2 ++ .../endpoints/test_dag_warning_endpoint.py | 2 ++ .../endpoints/test_dataset_endpoint.py | 2 ++ .../endpoints/test_event_log_endpoint.py | 2 ++ .../endpoints/test_extra_link_endpoint.py | 2 ++ .../endpoints/test_health_endpoint.py | 2 ++ .../endpoints/test_import_error_endpoint.py | 2 ++ .../endpoints/test_log_endpoint.py | 2 ++ .../test_mapped_task_instance_endpoint.py | 2 ++ .../endpoints/test_plugin_endpoint.py | 2 ++ .../endpoints/test_pool_endpoint.py | 2 ++ .../endpoints/test_provider_endpoint.py | 2 ++ .../endpoints/test_task_endpoint.py | 2 ++ .../endpoints/test_task_instance_endpoint.py | 2 ++ .../endpoints/test_variable_endpoint.py | 2 ++ .../endpoints/test_version_endpoint.py | 2 ++ .../endpoints/test_xcom_endpoint.py | 2 ++ .../schemas/test_connection_schema.py | 2 ++ .../schemas/test_dag_run_schema.py | 2 ++ .../api_connexion/schemas/test_dag_schema.py | 3 +++ .../schemas/test_dataset_schema.py | 3 +++ .../schemas/test_error_schema.py | 4 ++++ .../schemas/test_event_log_schema.py | 2 ++ .../schemas/test_pool_schemas.py | 4 ++++ .../test_role_and_permission_schema.py | 2 ++ .../schemas/test_task_instance_schema.py | 1 + .../api_connexion/schemas/test_user_schema.py | 2 ++ .../api_connexion/schemas/test_xcom_schema.py | 2 ++ tests/api_connexion/test_auth.py | 2 ++ tests/api_connexion/test_cors.py | 2 ++ tests/api_connexion/test_error_handling.py | 4 ++++ tests/api_connexion/test_security.py | 2 ++ .../auth/backend/test_basic_auth.py | 2 ++ .../client/test_local_client.py | 2 ++ .../common/experimental/test_pool.py | 2 ++ .../common/test_delete_dag.py | 2 ++ .../common/test_mark_tasks.py | 2 ++ .../common/test_trigger_dag.py | 2 ++ .../endpoints/test_rpc_api_endpoint.py | 2 ++ .../test_role_and_permission_endpoint.py | 2 ++ .../fab/api_endpoints/test_user_endpoint.py | 2 ++ .../fab/cli_commands/test_role_command.py | 2 ++ .../cli_commands/test_sync_perm_command.py | 4 ++++ .../fab/cli_commands/test_user_command.py | 2 ++ tests/callbacks/test_callback_requests.py | 1 + tests/cli/commands/test_celery_command.py | 2 ++ tests/cli/commands/test_connection_command.py | 2 ++ tests/cli/commands/test_dag_command.py | 2 ++ .../commands/test_dag_processor_command.py | 2 ++ tests/cli/commands/test_db_command.py | 2 ++ tests/cli/commands/test_info_command.py | 2 ++ .../cli/commands/test_internal_api_command.py | 1 + tests/cli/commands/test_jobs_command.py | 1 + tests/cli/commands/test_kerberos_command.py | 4 ++++ tests/cli/commands/test_kubernetes_command.py | 3 +++ tests/cli/commands/test_pool_command.py | 2 ++ .../test_rotate_fernet_key_command.py | 3 +++ tests/cli/commands/test_scheduler_command.py | 2 ++ tests/cli/commands/test_task_command.py | 3 +++ tests/cli/commands/test_triggerer_command.py | 4 ++++ tests/cli/commands/test_variable_command.py | 2 ++ tests/cli/commands/test_webserver_command.py | 1 + tests/cli/test_cli_parser.py | 1 + tests/conftest.py | 8 +++++++ tests/core/test_core.py | 2 ++ tests/core/test_impersonation_tests.py | 2 ++ tests/core/test_sentry.py | 2 ++ tests/core/test_sqlalchemy_config.py | 2 ++ tests/dag_processing/test_job_runner.py | 3 +++ tests/dag_processing/test_processor.py | 2 ++ tests/dags/test_clear_subdag.py | 4 ++++ tests/datasets/test_manager.py | 2 ++ .../decorators/test_branch_external_python.py | 2 ++ tests/decorators/test_branch_python.py | 2 ++ tests/decorators/test_branch_virtualenv.py | 2 ++ tests/decorators/test_external_python.py | 3 +++ tests/decorators/test_python.py | 3 +++ tests/decorators/test_python_virtualenv.py | 2 ++ tests/decorators/test_sensor.py | 2 ++ tests/decorators/test_setup_teardown.py | 2 ++ tests/decorators/test_short_circuit.py | 4 ++++ tests/decorators/test_task_group.py | 2 ++ tests/executors/test_base_executor.py | 4 ++++ tests/executors/test_executor_loader.py | 2 ++ tests/executors/test_local_executor.py | 4 ++++ tests/jobs/test_backfill_job.py | 2 ++ tests/jobs/test_base_job.py | 2 ++ tests/jobs/test_local_task_job.py | 2 ++ tests/jobs/test_scheduler_job.py | 2 ++ tests/jobs/test_triggerer_job.py | 2 ++ tests/lineage/test_lineage.py | 4 ++++ tests/listeners/test_listeners.py | 3 +++ tests/models/test_base.py | 2 ++ tests/models/test_baseoperator.py | 13 +++++++++++ tests/models/test_cleartasks.py | 2 ++ tests/models/test_dag.py | 2 ++ tests/models/test_dagbag.py | 2 ++ tests/models/test_dagcode.py | 2 ++ tests/models/test_dagrun.py | 3 +++ tests/models/test_dagwarning.py | 3 +++ tests/models/test_mappedoperator.py | 2 ++ tests/models/test_param.py | 4 ++++ tests/models/test_pool.py | 2 ++ tests/models/test_renderedtifields.py | 3 +++ tests/models/test_serialized_dag.py | 2 ++ tests/models/test_skipmixin.py | 3 +++ tests/models/test_taskinstance.py | 2 ++ tests/models/test_taskmixin.py | 2 ++ tests/models/test_timestamp.py | 2 ++ tests/models/test_trigger.py | 2 ++ tests/models/test_variable.py | 2 ++ tests/models/test_xcom.py | 3 +++ tests/models/test_xcom_arg.py | 3 +++ tests/models/test_xcom_arg_map.py | 2 ++ tests/notifications/test_basenotifier.py | 3 +++ tests/operators/test_bash.py | 2 ++ tests/operators/test_branch_operator.py | 4 ++++ tests/operators/test_datetime.py | 2 ++ tests/operators/test_email.py | 4 ++++ tests/operators/test_generic_transfer.py | 2 ++ tests/operators/test_latest_only_operator.py | 4 ++++ tests/operators/test_python.py | 3 +++ tests/operators/test_subdag_operator.py | 2 ++ tests/operators/test_trigger_dagrun.py | 2 ++ tests/operators/test_weekday.py | 2 ++ tests/plugins/test_plugins_manager.py | 4 ++++ tests/providers/airbyte/hooks/test_airbyte.py | 2 ++ .../cloud/log/test_oss_task_handler.py | 2 ++ .../aws/executors/ecs/test_ecs_executor.py | 2 ++ .../amazon/aws/hooks/test_base_aws.py | 2 ++ .../providers/amazon/aws/hooks/test_chime.py | 2 ++ tests/providers/amazon/aws/hooks/test_emr.py | 1 + tests/providers/amazon/aws/hooks/test_s3.py | 1 + .../providers/amazon/aws/links/test_links.py | 1 + .../aws/log/test_cloudwatch_task_handler.py | 1 + .../amazon/aws/log/test_s3_task_handler.py | 1 + .../amazon/aws/notifications/test_chime.py | 4 ++++ .../amazon/aws/notifications/test_sns.py | 1 + .../amazon/aws/notifications/test_sqs.py | 1 + .../amazon/aws/operators/test_appflow.py | 7 ++++++ .../amazon/aws/operators/test_athena.py | 1 + .../amazon/aws/operators/test_base_aws.py | 1 + .../amazon/aws/operators/test_datasync.py | 5 +++++ .../aws/operators/test_dms_describe_tasks.py | 3 +++ .../aws/operators/test_emr_add_steps.py | 2 ++ .../aws/operators/test_emr_create_job_flow.py | 2 ++ .../aws/operators/test_sagemaker_base.py | 1 + .../amazon/aws/sensors/test_base_aws.py | 1 + .../providers/amazon/aws/sensors/test_ecs.py | 3 +++ .../amazon/aws/sensors/test_s3_key.py | 2 ++ .../aws/sensors/test_s3_keys_unchanged.py | 1 + .../amazon/aws/transfers/test_base.py | 1 + .../aws/transfers/test_dynamodb_to_s3.py | 1 + .../aws/transfers/test_google_api_to_s3.py | 2 ++ .../amazon/aws/transfers/test_mongo_to_s3.py | 3 +++ .../amazon/aws/transfers/test_s3_to_sftp.py | 4 ++++ .../amazon/aws/transfers/test_s3_to_sql.py | 2 ++ .../aws/transfers/test_salesforce_to_s3.py | 5 +++++ .../amazon/aws/transfers/test_sftp_to_s3.py | 2 ++ .../amazon/aws/triggers/test_serialization.py | 2 ++ .../aws/utils/test_connection_wrapper.py | 3 +++ .../amazon/aws/utils/test_suppress.py | 1 + .../apache/druid/operators/test_druid.py | 4 ++++ .../flink/operators/test_flink_kubernetes.py | 5 +++++ .../flink/sensors/test_flink_kubernetes.py | 3 +++ .../providers/apache/hive/hooks/test_hive.py | 3 +++ .../hive/sensors/test_named_hive_partition.py | 2 ++ .../hive/transfers/test_vertica_to_hive.py | 4 ++++ .../apache/kafka/hooks/test_admin_client.py | 2 ++ .../apache/kafka/hooks/test_consumer.py | 2 ++ .../apache/kafka/hooks/test_producer.py | 3 +++ .../apache/kafka/operators/test_consume.py | 5 +++++ .../apache/kafka/operators/test_produce.py | 5 +++++ .../apache/kafka/sensors/test_kafka.py | 3 +++ .../kafka/triggers/test_await_message.py | 2 ++ .../apache/kylin/hooks/test_kylin.py | 2 ++ .../apache/kylin/operators/test_kylin_cube.py | 1 + .../providers/apache/livy/hooks/test_livy.py | 3 +++ .../apache/livy/operators/test_livy.py | 3 +++ .../apache/livy/sensors/test_livy.py | 3 +++ .../apache/livy/triggers/test_livy.py | 2 ++ tests/providers/apache/pig/hooks/test_pig.py | 1 + .../apache/pig/operators/test_pig.py | 5 +++++ .../apache/pinot/hooks/test_pinot.py | 1 + .../apache/spark/hooks/test_spark_jdbc.py | 2 ++ .../apache/spark/hooks/test_spark_sql.py | 2 ++ .../apache/spark/hooks/test_spark_submit.py | 2 ++ .../spark/operators/test_spark_submit.py | 3 +++ .../apache/sqoop/hooks/test_sqoop.py | 2 ++ .../apprise/notifications/test_apprise.py | 3 +++ .../providers/arangodb/hooks/test_arangodb.py | 5 +++++ .../arangodb/sensors/test_arangodb.py | 5 +++++ .../asana/operators/test_asana_tasks.py | 5 +++++ .../atlassian/jira/hooks/test_jira.py | 5 +++++ .../atlassian/jira/operators/test_jira.py | 5 +++++ .../atlassian/jira/sensors/test_jira.py | 4 ++++ .../celery/executors/test_celery_executor.py | 3 +++ .../providers/cloudant/hooks/test_cloudant.py | 2 ++ .../kubernetes/decorators/test_kubernetes.py | 3 +++ .../executors/test_kubernetes_executor.py | 22 +++++++++++++++++++ .../cncf/kubernetes/hooks/test_kubernetes.py | 3 +++ .../cncf/kubernetes/operators/test_pod.py | 3 +++ .../sensors/test_spark_kubernetes.py | 3 +++ .../kubernetes/test_template_rendering.py | 3 +++ tests/providers/common/sql/hooks/test_sql.py | 2 ++ .../common/sql/operators/test_sql.py | 11 ++++++++++ .../providers/common/sql/sensors/test_sql.py | 2 ++ .../daskexecutor/test_dask_executor.py | 2 ++ .../databricks/hooks/test_databricks.py | 15 +++++++++++++ .../databricks/hooks/test_databricks_sql.py | 2 ++ .../databricks/operators/test_databricks.py | 4 ++++ .../sensors/test_databricks_partition.py | 1 + .../databricks/sensors/test_databricks_sql.py | 1 + .../databricks/triggers/test_databricks.py | 3 +++ .../providers/datadog/sensors/test_datadog.py | 2 ++ .../dbt/cloud/hooks/test_dbt_cloud.py | 2 ++ .../dbt/cloud/operators/test_dbt_cloud.py | 2 ++ .../dbt/cloud/sensors/test_dbt_cloud.py | 3 +++ .../providers/dingding/hooks/test_dingding.py | 2 ++ .../discord/hooks/test_discord_webhook.py | 2 ++ .../discord/notifications/test_discord.py | 2 ++ .../docker/decorators/test_docker.py | 3 +++ .../elasticsearch/log/test_es_task_handler.py | 3 +++ tests/providers/exasol/hooks/test_sql.py | 3 +++ tests/providers/ftp/hooks/test_ftp.py | 3 +++ tests/providers/github/hooks/test_github.py | 4 ++++ .../providers/github/operators/test_github.py | 5 +++++ tests/providers/github/sensors/test_github.py | 5 +++++ .../google/cloud/hooks/test_bigquery.py | 12 ++++++++++ .../google/cloud/hooks/test_bigquery_dts.py | 1 + .../google/cloud/hooks/test_cloud_batch.py | 2 ++ .../google/cloud/hooks/test_cloud_build.py | 1 + .../google/cloud/hooks/test_cloud_run.py | 1 + .../google/cloud/hooks/test_compute_ssh.py | 3 +++ .../google/cloud/hooks/test_dataflow.py | 2 ++ .../google/cloud/hooks/test_dataform.py | 3 +++ .../google/cloud/hooks/test_datapipeline.py | 5 +++++ .../google/cloud/hooks/test_dataproc.py | 1 + .../providers/google/cloud/hooks/test_gcs.py | 1 + .../cloud/hooks/test_kubernetes_engine.py | 1 + .../google/cloud/hooks/test_mlengine.py | 1 + .../google/cloud/hooks/test_stackdriver.py | 1 + .../google/cloud/log/test_gcs_task_handler.py | 1 + .../log/test_stackdriver_task_handler.py | 1 + .../google/cloud/operators/test_bigquery.py | 18 +++++++++++++++ .../test_cloud_storage_transfer_service.py | 10 +++++++++ .../google/cloud/operators/test_compute.py | 4 ++++ .../google/cloud/operators/test_dataflow.py | 2 ++ .../google/cloud/operators/test_dataprep.py | 3 +++ .../google/cloud/operators/test_dataproc.py | 7 ++++++ .../google/cloud/operators/test_functions.py | 1 + .../cloud/operators/test_kubernetes_engine.py | 2 ++ .../cloud/secrets/test_secret_manager.py | 2 ++ .../cloud/sensors/test_cloud_composer.py | 1 + .../cloud/transfers/test_cassandra_to_gcs.py | 3 +++ .../cloud/transfers/test_gcs_to_bigquery.py | 1 + .../cloud/transfers/test_local_to_gcs.py | 3 +++ .../google/cloud/transfers/test_s3_to_gcs.py | 1 + .../cloud/transfers/test_salesforce_to_gcs.py | 3 +++ .../google/cloud/transfers/test_sql_to_gcs.py | 1 + .../google/cloud/triggers/test_bigquery.py | 3 +++ .../google/cloud/triggers/test_dataproc.py | 2 ++ .../cloud/triggers/test_kubernetes_engine.py | 1 + .../cloud/utils/test_credentials_provider.py | 1 + .../utils/test_mlengine_operator_utils.py | 1 + .../common/auth_backend/test_google_openid.py | 1 + .../google/common/hooks/test_base_google.py | 2 ++ .../google/common/hooks/test_discovery_api.py | 4 ++++ .../operators/test_campaign_manager.py | 1 + .../operators/test_display_video.py | 1 + .../operators/test_search_ads.py | 1 + .../sensors/test_search_ads.py | 4 ++++ .../google/suite/hooks/test_drive.py | 3 +++ tests/providers/http/hooks/test_http.py | 4 ++++ tests/providers/http/sensors/test_http.py | 3 +++ tests/providers/imap/hooks/test_imap.py | 3 +++ tests/providers/jdbc/hooks/test_jdbc.py | 5 +++++ .../microsoft/azure/hooks/test_adx.py | 2 ++ .../microsoft/azure/hooks/test_base_azure.py | 2 ++ .../microsoft/azure/hooks/test_wasb.py | 3 +++ .../azure/log/test_wasb_task_handler.py | 3 +++ .../microsoft/azure/operators/test_adx.py | 2 ++ .../operators/test_azure_data_factory.py | 1 + .../microsoft/mssql/hooks/test_mssql.py | 1 + .../microsoft/winrm/hooks/test_winrm.py | 2 ++ tests/providers/mongo/hooks/test_mongo.py | 2 ++ .../mysql/transfers/test_s3_to_mysql.py | 2 ++ .../extractors/test_bash_extractor.py | 2 ++ .../extractors/test_default_extractor.py | 4 ++++ .../extractors/test_python_extractor.py | 2 ++ .../openlineage/plugins/test_listener.py | 3 +++ .../plugins/test_openlineage_adapter.py | 2 ++ .../openlineage/plugins/test_utils.py | 2 ++ .../providers/openlineage/utils/test_utils.py | 3 +++ .../opensearch/hooks/test_opensearch.py | 5 +++++ .../opensearch/operators/test_opensearch.py | 3 +++ .../providers/opsgenie/hooks/test_opsgenie.py | 2 ++ .../providers/oracle/operators/test_oracle.py | 1 + .../pagerduty/hooks/test_pagerduty.py | 3 +++ .../pagerduty/hooks/test_pagerduty_events.py | 2 ++ .../pagerduty/notifications/test_pagerduty.py | 5 +++++ .../papermill/operators/test_papermill.py | 1 + .../postgres/operators/test_postgres.py | 1 + tests/providers/redis/hooks/test_redis.py | 4 ++++ .../redis/log/test_redis_task_handler.py | 2 ++ .../salesforce/hooks/test_salesforce.py | 5 +++++ .../sftp/decorators/sensors/test_sftp.py | 3 +++ tests/providers/sftp/hooks/test_sftp.py | 2 ++ tests/providers/sftp/operators/test_sftp.py | 3 +++ .../slack/notifications/test_slack.py | 2 ++ .../slack/notifications/test_slack_webhook.py | 2 ++ .../slack/transfers/test_sql_to_slack.py | 1 + tests/providers/smtp/hooks/test_smtp.py | 3 +++ .../providers/smtp/notifications/test_smtp.py | 4 ++++ .../snowflake/operators/test_snowflake.py | 1 + tests/providers/sqlite/hooks/test_sqlite.py | 3 +++ tests/providers/ssh/hooks/test_ssh.py | 3 +++ tests/providers/ssh/operators/test_ssh.py | 3 +++ tests/providers/tableau/hooks/test_tableau.py | 2 ++ tests/providers/tabular/hooks/test_tabular.py | 3 +++ .../providers/telegram/hooks/test_telegram.py | 3 +++ .../telegram/operators/test_telegram.py | 2 ++ tests/providers/zendesk/hooks/test_zendesk.py | 2 ++ tests/security/test_kerberos.py | 2 ++ tests/sensors/test_base.py | 2 ++ tests/sensors/test_external_task_sensor.py | 3 +++ tests/sensors/test_filesystem.py | 3 +++ tests/sensors/test_python.py | 2 ++ tests/sensors/test_time_delta.py | 5 +++++ tests/sensors/test_timeout_sensor.py | 2 ++ tests/sensors/test_weekday_sensor.py | 3 +++ tests/serialization/test_dag_serialization.py | 13 +++++++++++ tests/serialization/test_pydantic_models.py | 2 ++ .../serialization/test_serialized_objects.py | 1 + .../task/task_runner/test_base_task_runner.py | 2 ++ .../task_runner/test_standard_task_runner.py | 5 +++++ tests/task/task_runner/test_task_runner.py | 3 +++ .../deps/test_dag_ti_slots_available_dep.py | 4 ++++ tests/ti_deps/deps/test_dag_unpaused_dep.py | 4 ++++ tests/ti_deps/deps/test_dagrun_exists_dep.py | 4 ++++ tests/ti_deps/deps/test_dagrun_id_dep.py | 4 ++++ .../deps/test_not_in_retry_period_dep.py | 3 +++ .../deps/test_not_previously_skipped_dep.py | 2 ++ .../deps/test_pool_slots_available_dep.py | 4 ++++ tests/ti_deps/deps/test_prev_dagrun_dep.py | 2 ++ .../deps/test_ready_to_reschedule_dep.py | 3 +++ .../deps/test_runnable_exec_date_dep.py | 2 ++ tests/ti_deps/deps/test_task_concurrency.py | 2 ++ .../ti_deps/deps/test_task_not_running_dep.py | 4 ++++ tests/ti_deps/deps/test_trigger_rule_dep.py | 3 +++ tests/ti_deps/deps/test_valid_state_dep.py | 2 ++ tests/triggers/test_external_task.py | 2 ++ tests/utils/log/test_colored_log.py | 4 ++++ tests/utils/log/test_log_reader.py | 3 +++ tests/utils/test_cli_util.py | 2 ++ tests/utils/test_db.py | 2 ++ tests/utils/test_db_cleanup.py | 2 ++ tests/utils/test_dot_renderer.py | 4 ++++ tests/utils/test_helpers.py | 2 ++ tests/utils/test_log_handlers.py | 2 ++ tests/utils/test_process_utils.py | 2 ++ tests/utils/test_retries.py | 1 + tests/utils/test_session.py | 2 ++ tests/utils/test_sqlalchemy.py | 3 +++ tests/utils/test_state.py | 4 ++++ ...test_task_handler_with_custom_formatter.py | 3 +++ tests/utils/test_types.py | 4 ++++ .../experimental/test_dag_runs_endpoint.py | 2 ++ tests/www/api/experimental/test_endpoints.py | 2 ++ tests/www/test_app.py | 2 ++ tests/www/test_auth.py | 2 ++ tests/www/test_init_views.py | 2 ++ tests/www/test_security.py | 2 ++ tests/www/test_utils.py | 6 +++++ tests/www/views/test_session.py | 2 ++ tests/www/views/test_views.py | 2 ++ tests/www/views/test_views_acl.py | 2 ++ tests/www/views/test_views_base.py | 2 ++ tests/www/views/test_views_blocked.py | 2 ++ .../www/views/test_views_cluster_activity.py | 2 ++ tests/www/views/test_views_configuration.py | 4 ++++ tests/www/views/test_views_connection.py | 2 ++ .../www/views/test_views_custom_user_views.py | 2 ++ tests/www/views/test_views_dagrun.py | 2 ++ tests/www/views/test_views_dataset.py | 2 ++ tests/www/views/test_views_decorators.py | 2 ++ tests/www/views/test_views_extra_links.py | 2 ++ tests/www/views/test_views_grid.py | 2 ++ tests/www/views/test_views_home.py | 2 ++ tests/www/views/test_views_log.py | 2 ++ tests/www/views/test_views_mount.py | 2 ++ tests/www/views/test_views_pool.py | 2 ++ tests/www/views/test_views_rate_limit.py | 2 ++ tests/www/views/test_views_rendered.py | 2 ++ tests/www/views/test_views_robots.py | 4 ++++ tests/www/views/test_views_task_norun.py | 2 ++ tests/www/views/test_views_tasks.py | 2 ++ tests/www/views/test_views_trigger_dag.py | 2 ++ tests/www/views/test_views_variable.py | 1 + 407 files changed, 1096 insertions(+) diff --git a/tests/always/test_connection.py b/tests/always/test_connection.py index 262fb5e8506f0..9b0df4ea891d3 100644 --- a/tests/always/test_connection.py +++ b/tests/always/test_connection.py @@ -634,6 +634,7 @@ def test_param_setup(self): assert "airflow" == conn.password assert conn.port is None + @pytest.mark.db_test def test_env_var_priority(self): conn = SqliteHook.get_connection(conn_id="airflow_db") assert "ec2.compute.com" != conn.host @@ -705,6 +706,7 @@ def test_connection_mixed(self): ): Connection(conn_id="TEST_ID", uri="mysql://", schema="AAA") + @pytest.mark.db_test def test_masking_from_db(self): """Test secrets are masked when loaded directly from the DB""" from airflow.settings import Session diff --git a/tests/always/test_example_dags.py b/tests/always/test_example_dags.py index 6ffc923792c12..3687832fdc772 100644 --- a/tests/always/test_example_dags.py +++ b/tests/always/test_example_dags.py @@ -77,6 +77,7 @@ def relative_path(path): return os.path.relpath(path, AIRFLOW_SOURCES_ROOT.as_posix()) +@pytest.mark.db_test @pytest.mark.parametrize("example", example_not_suspended_dags(), ids=relative_path) def test_should_be_importable(example): dagbag = DagBag( @@ -87,6 +88,7 @@ def test_should_be_importable(example): assert len(dagbag.dag_ids) >= 1 +@pytest.mark.db_test @pytest.mark.parametrize("example", example_dags_except_db_exception(), ids=relative_path) def test_should_not_do_database_queries(example): with assert_queries_count(0): diff --git a/tests/always/test_secrets.py b/tests/always/test_secrets.py index 25245903bf50e..d258e1a70857f 100644 --- a/tests/always/test_secrets.py +++ b/tests/always/test_secrets.py @@ -19,6 +19,8 @@ from unittest import mock +import pytest + from airflow.configuration import ensure_secrets_loaded, initialize_secrets_backends from airflow.models import Connection, Variable from airflow.secrets.cache import SecretCache @@ -115,6 +117,7 @@ def test_backend_fallback_to_env_var(self, mock_get_connection): assert "mysql://airflow:airflow@host:5432/airflow" == conn.get_uri() +@pytest.mark.db_test class TestVariableFromSecrets: def setup_method(self) -> None: clear_db_variables() diff --git a/tests/always/test_secrets_backends.py b/tests/always/test_secrets_backends.py index f68c8f6012bbc..e862ed3263a6a 100644 --- a/tests/always/test_secrets_backends.py +++ b/tests/always/test_secrets_backends.py @@ -30,6 +30,8 @@ from airflow.utils.session import create_session from tests.test_utils.db import clear_db_connections, clear_db_variables +pytestmark = pytest.mark.db_test + class SampleConn: def __init__(self, conn_id, variation: str): diff --git a/tests/api_connexion/endpoints/test_config_endpoint.py b/tests/api_connexion/endpoints/test_config_endpoint.py index 17a159a4fb8a4..c091c4ef1c9f3 100644 --- a/tests/api_connexion/endpoints/test_config_endpoint.py +++ b/tests/api_connexion/endpoints/test_config_endpoint.py @@ -25,6 +25,9 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_user from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + MOCK_CONF = { "core": { "parallelism": "1024", diff --git a/tests/api_connexion/endpoints/test_connection_endpoint.py b/tests/api_connexion/endpoints/test_connection_endpoint.py index 24180b5052bc7..1dd3752873582 100644 --- a/tests/api_connexion/endpoints/test_connection_endpoint.py +++ b/tests/api_connexion/endpoints/test_connection_endpoint.py @@ -30,6 +30,8 @@ from tests.test_utils.db import clear_db_connections from tests.test_utils.www import _check_last_log +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_dag_endpoint.py b/tests/api_connexion/endpoints/test_dag_endpoint.py index f390564e5dec9..ef9f7d7519379 100644 --- a/tests/api_connexion/endpoints/test_dag_endpoint.py +++ b/tests/api_connexion/endpoints/test_dag_endpoint.py @@ -34,6 +34,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_db_serialized_dags +pytestmark = pytest.mark.db_test + @pytest.fixture() def current_file_token(url_safe_serializer) -> str: diff --git a/tests/api_connexion/endpoints/test_dag_run_endpoint.py b/tests/api_connexion/endpoints/test_dag_run_endpoint.py index 48331a66a3230..04367402066e8 100644 --- a/tests/api_connexion/endpoints/test_dag_run_endpoint.py +++ b/tests/api_connexion/endpoints/test_dag_run_endpoint.py @@ -39,6 +39,8 @@ from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_db_serialized_dags from tests.test_utils.www import _check_last_log +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_dag_source_endpoint.py b/tests/api_connexion/endpoints/test_dag_source_endpoint.py index c179157a22bd0..45e3037ceb352 100644 --- a/tests/api_connexion/endpoints/test_dag_source_endpoint.py +++ b/tests/api_connexion/endpoints/test_dag_source_endpoint.py @@ -27,6 +27,8 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_user from tests.test_utils.db import clear_db_dag_code, clear_db_dags, clear_db_serialized_dags +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from airflow.models.dag import DAG diff --git a/tests/api_connexion/endpoints/test_dag_warning_endpoint.py b/tests/api_connexion/endpoints/test_dag_warning_endpoint.py index 041a61634eb0c..9310956d24f63 100644 --- a/tests/api_connexion/endpoints/test_dag_warning_endpoint.py +++ b/tests/api_connexion/endpoints/test_dag_warning_endpoint.py @@ -27,6 +27,8 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_user from tests.test_utils.db import clear_db_dag_warnings, clear_db_dags +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_dataset_endpoint.py b/tests/api_connexion/endpoints/test_dataset_endpoint.py index c582b877113c6..e06505dc4a99b 100644 --- a/tests/api_connexion/endpoints/test_dataset_endpoint.py +++ b/tests/api_connexion/endpoints/test_dataset_endpoint.py @@ -32,6 +32,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_datasets, clear_db_runs +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_event_log_endpoint.py b/tests/api_connexion/endpoints/test_event_log_endpoint.py index d1e8af2facd51..6c1811506cf71 100644 --- a/tests/api_connexion/endpoints/test_event_log_endpoint.py +++ b/tests/api_connexion/endpoints/test_event_log_endpoint.py @@ -26,6 +26,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_logs +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_extra_link_endpoint.py b/tests/api_connexion/endpoints/test_extra_link_endpoint.py index 366bbb6246339..a52c034268104 100644 --- a/tests/api_connexion/endpoints/test_extra_link_endpoint.py +++ b/tests/api_connexion/endpoints/test_extra_link_endpoint.py @@ -37,6 +37,8 @@ from tests.test_utils.db import clear_db_runs, clear_db_xcom from tests.test_utils.mock_plugins import mock_plugin_manager +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_health_endpoint.py b/tests/api_connexion/endpoints/test_health_endpoint.py index efa552013857e..7d73b338e5105 100644 --- a/tests/api_connexion/endpoints/test_health_endpoint.py +++ b/tests/api_connexion/endpoints/test_health_endpoint.py @@ -30,6 +30,8 @@ HEALTHY = "healthy" UNHEALTHY = "unhealthy" +pytestmark = pytest.mark.db_test + class TestHealthTestBase: @pytest.fixture(autouse=True) diff --git a/tests/api_connexion/endpoints/test_import_error_endpoint.py b/tests/api_connexion/endpoints/test_import_error_endpoint.py index 83c2d3f2020c4..33550862ab95c 100644 --- a/tests/api_connexion/endpoints/test_import_error_endpoint.py +++ b/tests/api_connexion/endpoints/test_import_error_endpoint.py @@ -29,6 +29,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_import_errors +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_log_endpoint.py b/tests/api_connexion/endpoints/test_log_endpoint.py index 7ed1329d9df28..d472b6902b3b1 100644 --- a/tests/api_connexion/endpoints/test_log_endpoint.py +++ b/tests/api_connexion/endpoints/test_log_endpoint.py @@ -36,6 +36,8 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_user from tests.test_utils.db import clear_db_runs +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_mapped_task_instance_endpoint.py b/tests/api_connexion/endpoints/test_mapped_task_instance_endpoint.py index 7162ed1d4f8cc..49138cef2d4c1 100644 --- a/tests/api_connexion/endpoints/test_mapped_task_instance_endpoint.py +++ b/tests/api_connexion/endpoints/test_mapped_task_instance_endpoint.py @@ -37,6 +37,8 @@ from tests.test_utils.db import clear_db_runs, clear_db_sla_miss, clear_rendered_ti_fields from tests.test_utils.mock_operators import MockOperator +pytestmark = pytest.mark.db_test + DEFAULT_DATETIME_1 = datetime(2020, 1, 1) DEFAULT_DATETIME_STR_1 = "2020-01-01T00:00:00+00:00" DEFAULT_DATETIME_STR_2 = "2020-01-02T00:00:00+00:00" diff --git a/tests/api_connexion/endpoints/test_plugin_endpoint.py b/tests/api_connexion/endpoints/test_plugin_endpoint.py index 6a941d69977e3..4d9b8be847ca7 100644 --- a/tests/api_connexion/endpoints/test_plugin_endpoint.py +++ b/tests/api_connexion/endpoints/test_plugin_endpoint.py @@ -33,6 +33,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.mock_plugins import mock_plugin_manager +pytestmark = pytest.mark.db_test + class PluginHook(BaseHook): ... diff --git a/tests/api_connexion/endpoints/test_pool_endpoint.py b/tests/api_connexion/endpoints/test_pool_endpoint.py index a0121fccd185c..023dac388144b 100644 --- a/tests/api_connexion/endpoints/test_pool_endpoint.py +++ b/tests/api_connexion/endpoints/test_pool_endpoint.py @@ -26,6 +26,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_pools +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_provider_endpoint.py b/tests/api_connexion/endpoints/test_provider_endpoint.py index b970f5f47091b..621419114ea74 100644 --- a/tests/api_connexion/endpoints/test_provider_endpoint.py +++ b/tests/api_connexion/endpoints/test_provider_endpoint.py @@ -24,6 +24,8 @@ from airflow.security import permissions from tests.test_utils.api_connexion_utils import create_user, delete_user +pytestmark = pytest.mark.db_test + MOCK_PROVIDERS = { "apache-airflow-providers-amazon": ProviderInfo( "1.0.0", diff --git a/tests/api_connexion/endpoints/test_task_endpoint.py b/tests/api_connexion/endpoints/test_task_endpoint.py index df4f72e9c7ff5..b2ebcdb7f9907 100644 --- a/tests/api_connexion/endpoints/test_task_endpoint.py +++ b/tests/api_connexion/endpoints/test_task_endpoint.py @@ -31,6 +31,8 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_user from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_db_serialized_dags +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_task_instance_endpoint.py b/tests/api_connexion/endpoints/test_task_instance_endpoint.py index 136b01a5843d2..0c445c155dc23 100644 --- a/tests/api_connexion/endpoints/test_task_instance_endpoint.py +++ b/tests/api_connexion/endpoints/test_task_instance_endpoint.py @@ -38,6 +38,8 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_roles, delete_user from tests.test_utils.db import clear_db_runs, clear_db_sla_miss, clear_rendered_ti_fields +pytestmark = pytest.mark.db_test + DEFAULT_DATETIME_1 = datetime(2020, 1, 1) DEFAULT_DATETIME_STR_1 = "2020-01-01T00:00:00+00:00" DEFAULT_DATETIME_STR_2 = "2020-01-02T00:00:00+00:00" diff --git a/tests/api_connexion/endpoints/test_variable_endpoint.py b/tests/api_connexion/endpoints/test_variable_endpoint.py index c622e0d673ce4..df8cfdc2104a6 100644 --- a/tests/api_connexion/endpoints/test_variable_endpoint.py +++ b/tests/api_connexion/endpoints/test_variable_endpoint.py @@ -28,6 +28,8 @@ from tests.test_utils.db import clear_db_variables from tests.test_utils.www import _check_last_log +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/endpoints/test_version_endpoint.py b/tests/api_connexion/endpoints/test_version_endpoint.py index 362227049f5ab..6c21985a73584 100644 --- a/tests/api_connexion/endpoints/test_version_endpoint.py +++ b/tests/api_connexion/endpoints/test_version_endpoint.py @@ -20,6 +20,8 @@ import pytest +pytestmark = pytest.mark.db_test + class TestGetHealthTest: @pytest.fixture(autouse=True) diff --git a/tests/api_connexion/endpoints/test_xcom_endpoint.py b/tests/api_connexion/endpoints/test_xcom_endpoint.py index 9e175ab488d3e..c4919314c5acc 100644 --- a/tests/api_connexion/endpoints/test_xcom_endpoint.py +++ b/tests/api_connexion/endpoints/test_xcom_endpoint.py @@ -35,6 +35,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_db_xcom +pytestmark = pytest.mark.db_test + class CustomXCom(BaseXCom): @classmethod diff --git a/tests/api_connexion/schemas/test_connection_schema.py b/tests/api_connexion/schemas/test_connection_schema.py index 9584941691f8a..0da0851fe491e 100644 --- a/tests/api_connexion/schemas/test_connection_schema.py +++ b/tests/api_connexion/schemas/test_connection_schema.py @@ -32,6 +32,8 @@ from airflow.utils.session import create_session, provide_session from tests.test_utils.db import clear_db_connections +pytestmark = pytest.mark.db_test + class TestConnectionCollectionItemSchema: def setup_method(self) -> None: diff --git a/tests/api_connexion/schemas/test_dag_run_schema.py b/tests/api_connexion/schemas/test_dag_run_schema.py index 74a119ca55cc2..ce187868c78f3 100644 --- a/tests/api_connexion/schemas/test_dag_run_schema.py +++ b/tests/api_connexion/schemas/test_dag_run_schema.py @@ -35,6 +35,8 @@ SECOND_TIME = "2020-06-10T13:59:56.336000+00:00" +pytestmark = pytest.mark.db_test + class TestDAGRunBase: def setup_method(self) -> None: diff --git a/tests/api_connexion/schemas/test_dag_schema.py b/tests/api_connexion/schemas/test_dag_schema.py index e66d7d14797f0..8774f182ba500 100644 --- a/tests/api_connexion/schemas/test_dag_schema.py +++ b/tests/api_connexion/schemas/test_dag_schema.py @@ -18,6 +18,8 @@ from datetime import datetime +import pytest + from airflow.api_connexion.schemas.dag_schema import ( DAGCollection, DAGCollectionSchema, @@ -141,6 +143,7 @@ def test_serialize_test_dag_collection_schema(url_safe_serializer): } == schema.dump(instance) +@pytest.mark.db_test def test_serialize_test_dag_detail_schema(url_safe_serializer): dag = DAG( dag_id="test_dag", diff --git a/tests/api_connexion/schemas/test_dataset_schema.py b/tests/api_connexion/schemas/test_dataset_schema.py index b8b0d2f44007b..9dd0d7d7f72f8 100644 --- a/tests/api_connexion/schemas/test_dataset_schema.py +++ b/tests/api_connexion/schemas/test_dataset_schema.py @@ -16,6 +16,7 @@ # under the License. from __future__ import annotations +import pytest import time_machine from airflow.api_connexion.schemas.dataset_schema import ( @@ -31,6 +32,8 @@ from airflow.operators.empty import EmptyOperator from tests.test_utils.db import clear_db_dags, clear_db_datasets +pytestmark = pytest.mark.db_test + class TestDatasetSchemaBase: def setup_method(self) -> None: diff --git a/tests/api_connexion/schemas/test_error_schema.py b/tests/api_connexion/schemas/test_error_schema.py index ca150ac6f2a20..5cb6873a9eaa6 100644 --- a/tests/api_connexion/schemas/test_error_schema.py +++ b/tests/api_connexion/schemas/test_error_schema.py @@ -16,6 +16,8 @@ # under the License. from __future__ import annotations +import pytest + from airflow.api_connexion.schemas.error_schema import ( ImportErrorCollection, import_error_collection_schema, @@ -26,6 +28,8 @@ from airflow.utils.session import provide_session from tests.test_utils.db import clear_db_import_errors +pytestmark = pytest.mark.db_test + class TestErrorSchemaBase: def setup_method(self) -> None: diff --git a/tests/api_connexion/schemas/test_event_log_schema.py b/tests/api_connexion/schemas/test_event_log_schema.py index cefa3136541b8..bf0b23d2974b2 100644 --- a/tests/api_connexion/schemas/test_event_log_schema.py +++ b/tests/api_connexion/schemas/test_event_log_schema.py @@ -26,6 +26,8 @@ from airflow.models import Log from airflow.utils import timezone +pytestmark = pytest.mark.db_test + @pytest.fixture def task_instance(session, create_task_instance, request): diff --git a/tests/api_connexion/schemas/test_pool_schemas.py b/tests/api_connexion/schemas/test_pool_schemas.py index 9c5a78994db43..d3080061e0af0 100644 --- a/tests/api_connexion/schemas/test_pool_schemas.py +++ b/tests/api_connexion/schemas/test_pool_schemas.py @@ -16,11 +16,15 @@ # under the License. from __future__ import annotations +import pytest + from airflow.api_connexion.schemas.pool_schema import PoolCollection, pool_collection_schema, pool_schema from airflow.models.pool import Pool from airflow.utils.session import provide_session from tests.test_utils.db import clear_db_pools +pytestmark = pytest.mark.db_test + class TestPoolSchema: def setup_method(self) -> None: diff --git a/tests/api_connexion/schemas/test_role_and_permission_schema.py b/tests/api_connexion/schemas/test_role_and_permission_schema.py index 0b8783298fb35..a8a4924216838 100644 --- a/tests/api_connexion/schemas/test_role_and_permission_schema.py +++ b/tests/api_connexion/schemas/test_role_and_permission_schema.py @@ -26,6 +26,8 @@ from airflow.security import permissions from tests.test_utils.api_connexion_utils import create_role, delete_role +pytestmark = pytest.mark.db_test + class TestRoleCollectionItemSchema: @pytest.fixture(scope="class") diff --git a/tests/api_connexion/schemas/test_task_instance_schema.py b/tests/api_connexion/schemas/test_task_instance_schema.py index e46d0f8a5b272..76047498d27a3 100644 --- a/tests/api_connexion/schemas/test_task_instance_schema.py +++ b/tests/api_connexion/schemas/test_task_instance_schema.py @@ -33,6 +33,7 @@ from airflow.utils.timezone import datetime +@pytest.mark.db_test class TestTaskInstanceSchema: @pytest.fixture(autouse=True) def set_attrs(self, session, dag_maker): diff --git a/tests/api_connexion/schemas/test_user_schema.py b/tests/api_connexion/schemas/test_user_schema.py index cf52e61b85251..47955304be0e5 100644 --- a/tests/api_connexion/schemas/test_user_schema.py +++ b/tests/api_connexion/schemas/test_user_schema.py @@ -27,6 +27,8 @@ DEFAULT_TIME = "2021-01-09T13:59:56.336000+00:00" +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_connexion/schemas/test_xcom_schema.py b/tests/api_connexion/schemas/test_xcom_schema.py index f12b5b2f776b8..7d83cdcc57890 100644 --- a/tests/api_connexion/schemas/test_xcom_schema.py +++ b/tests/api_connexion/schemas/test_xcom_schema.py @@ -31,6 +31,8 @@ from airflow.utils.dates import parse_execution_date from airflow.utils.session import create_session +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module", autouse=True) def clean_xcom(): diff --git a/tests/api_connexion/test_auth.py b/tests/api_connexion/test_auth.py index b4cdc4a2bc7e6..869b69990f00c 100644 --- a/tests/api_connexion/test_auth.py +++ b/tests/api_connexion/test_auth.py @@ -26,6 +26,8 @@ from tests.test_utils.db import clear_db_pools from tests.test_utils.www import client_with_login +pytestmark = pytest.mark.db_test + class BaseTestAuth: @pytest.fixture(autouse=True) diff --git a/tests/api_connexion/test_cors.py b/tests/api_connexion/test_cors.py index cff605780e78b..4dc4950df9946 100644 --- a/tests/api_connexion/test_cors.py +++ b/tests/api_connexion/test_cors.py @@ -23,6 +23,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_pools +pytestmark = pytest.mark.db_test + class BaseTestAuth: @pytest.fixture(autouse=True) diff --git a/tests/api_connexion/test_error_handling.py b/tests/api_connexion/test_error_handling.py index 0c8d9a9bd2165..d89515d05b68f 100644 --- a/tests/api_connexion/test_error_handling.py +++ b/tests/api_connexion/test_error_handling.py @@ -16,6 +16,10 @@ # under the License. from __future__ import annotations +import pytest + +pytestmark = pytest.mark.db_test + def test_incorrect_endpoint_should_return_json(minimal_app_for_api): client = minimal_app_for_api.test_client() diff --git a/tests/api_connexion/test_security.py b/tests/api_connexion/test_security.py index 136ababa8848e..e75eba53e40f4 100644 --- a/tests/api_connexion/test_security.py +++ b/tests/api_connexion/test_security.py @@ -21,6 +21,8 @@ from airflow.security import permissions from tests.test_utils.api_connexion_utils import create_user, delete_user +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_api): diff --git a/tests/api_experimental/auth/backend/test_basic_auth.py b/tests/api_experimental/auth/backend/test_basic_auth.py index 06d7726914099..0d84465dd0446 100644 --- a/tests/api_experimental/auth/backend/test_basic_auth.py +++ b/tests/api_experimental/auth/backend/test_basic_auth.py @@ -23,6 +23,8 @@ from tests.test_utils.db import clear_db_pools +pytestmark = pytest.mark.db_test + class TestBasicAuth: @pytest.fixture(autouse=True) diff --git a/tests/api_experimental/client/test_local_client.py b/tests/api_experimental/client/test_local_client.py index e742394221e7e..b02a5a5c42297 100644 --- a/tests/api_experimental/client/test_local_client.py +++ b/tests/api_experimental/client/test_local_client.py @@ -39,6 +39,8 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_pools +pytestmark = pytest.mark.db_test + EXECDATE = timezone.utcnow() EXECDATE_NOFRACTIONS = EXECDATE.replace(microsecond=0) EXECDATE_ISO = EXECDATE_NOFRACTIONS.isoformat() diff --git a/tests/api_experimental/common/experimental/test_pool.py b/tests/api_experimental/common/experimental/test_pool.py index e030cbe84d54d..3f3cbe846ae1b 100644 --- a/tests/api_experimental/common/experimental/test_pool.py +++ b/tests/api_experimental/common/experimental/test_pool.py @@ -29,6 +29,8 @@ from airflow.utils.session import create_session from tests.test_utils.db import clear_db_pools +pytestmark = pytest.mark.db_test + @pytest.mark.filterwarnings("ignore::DeprecationWarning") class TestPool: diff --git a/tests/api_experimental/common/test_delete_dag.py b/tests/api_experimental/common/test_delete_dag.py index b54a1c99bd477..a97e6e2bca819 100644 --- a/tests/api_experimental/common/test_delete_dag.py +++ b/tests/api_experimental/common/test_delete_dag.py @@ -35,6 +35,8 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + class TestDeleteDAGCatchError: def test_delete_dag_non_existent_dag(self): diff --git a/tests/api_experimental/common/test_mark_tasks.py b/tests/api_experimental/common/test_mark_tasks.py index e634c592b7e57..47c10fa185395 100644 --- a/tests/api_experimental/common/test_mark_tasks.py +++ b/tests/api_experimental/common/test_mark_tasks.py @@ -43,6 +43,8 @@ DEV_NULL = "/dev/null" +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def dagbag(): diff --git a/tests/api_experimental/common/test_trigger_dag.py b/tests/api_experimental/common/test_trigger_dag.py index 4a3b5444ee770..bfd9d3fd2dc8d 100644 --- a/tests/api_experimental/common/test_trigger_dag.py +++ b/tests/api_experimental/common/test_trigger_dag.py @@ -28,6 +28,8 @@ from airflow.utils import timezone from tests.test_utils import db +pytestmark = pytest.mark.db_test + class TestTriggerDag: def setup_method(self) -> None: diff --git a/tests/api_internal/endpoints/test_rpc_api_endpoint.py b/tests/api_internal/endpoints/test_rpc_api_endpoint.py index a067decad1f35..17062752b647f 100644 --- a/tests/api_internal/endpoints/test_rpc_api_endpoint.py +++ b/tests/api_internal/endpoints/test_rpc_api_endpoint.py @@ -34,6 +34,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.decorators import dont_initialize_flask_app_submodules +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from flask import Flask diff --git a/tests/auth/managers/fab/api_endpoints/test_role_and_permission_endpoint.py b/tests/auth/managers/fab/api_endpoints/test_role_and_permission_endpoint.py index b8a8d836998ae..d55cce591a31d 100644 --- a/tests/auth/managers/fab/api_endpoints/test_role_and_permission_endpoint.py +++ b/tests/auth/managers/fab/api_endpoints/test_role_and_permission_endpoint.py @@ -30,6 +30,8 @@ delete_user, ) +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_app(minimal_app_for_auth_api): diff --git a/tests/auth/managers/fab/api_endpoints/test_user_endpoint.py b/tests/auth/managers/fab/api_endpoints/test_user_endpoint.py index 51427ddfcbeb0..bea8b8dab4a78 100644 --- a/tests/auth/managers/fab/api_endpoints/test_user_endpoint.py +++ b/tests/auth/managers/fab/api_endpoints/test_user_endpoint.py @@ -29,6 +29,8 @@ from tests.test_utils.api_connexion_utils import assert_401, create_user, delete_user from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + DEFAULT_TIME = "2020-06-11T18:00:00+00:00" diff --git a/tests/auth/managers/fab/cli_commands/test_role_command.py b/tests/auth/managers/fab/cli_commands/test_role_command.py index ea60bb5d9e773..d37707d752b6b 100644 --- a/tests/auth/managers/fab/cli_commands/test_role_command.py +++ b/tests/auth/managers/fab/cli_commands/test_role_command.py @@ -29,6 +29,8 @@ from airflow.cli import cli_parser from airflow.security import permissions +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from airflow.auth.managers.fab.models import Role diff --git a/tests/auth/managers/fab/cli_commands/test_sync_perm_command.py b/tests/auth/managers/fab/cli_commands/test_sync_perm_command.py index d59fb34a8ced6..34b0ca662689a 100644 --- a/tests/auth/managers/fab/cli_commands/test_sync_perm_command.py +++ b/tests/auth/managers/fab/cli_commands/test_sync_perm_command.py @@ -19,9 +19,13 @@ from unittest import mock +import pytest + from airflow.auth.managers.fab.cli_commands import sync_perm_command from airflow.cli import cli_parser +pytestmark = pytest.mark.db_test + class TestCliSyncPerm: @classmethod diff --git a/tests/auth/managers/fab/cli_commands/test_user_command.py b/tests/auth/managers/fab/cli_commands/test_user_command.py index 501f6826b7c60..e4fccf706373d 100644 --- a/tests/auth/managers/fab/cli_commands/test_user_command.py +++ b/tests/auth/managers/fab/cli_commands/test_user_command.py @@ -29,6 +29,8 @@ from airflow.cli import cli_parser from tests.test_utils.api_connexion_utils import delete_users +pytestmark = pytest.mark.db_test + TEST_USER1_EMAIL = "test-user1@example.com" TEST_USER2_EMAIL = "test-user2@example.com" TEST_USER3_EMAIL = "test-user3@example.com" diff --git a/tests/callbacks/test_callback_requests.py b/tests/callbacks/test_callback_requests.py index 14f547c02f262..4d9e7214b56b7 100644 --- a/tests/callbacks/test_callback_requests.py +++ b/tests/callbacks/test_callback_requests.py @@ -32,6 +32,7 @@ from airflow.utils import timezone from airflow.utils.state import State +pytestmark = pytest.mark.db_test TI = TaskInstance( task=BashOperator(task_id="test", bash_command="true", dag=DAG(dag_id="id"), start_date=datetime.now()), run_id="fake_run", diff --git a/tests/cli/commands/test_celery_command.py b/tests/cli/commands/test_celery_command.py index 02f26d7f23f69..9527adf9be680 100644 --- a/tests/cli/commands/test_celery_command.py +++ b/tests/cli/commands/test_celery_command.py @@ -31,6 +31,8 @@ from airflow.configuration import conf from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestWorkerPrecheck: @mock.patch("airflow.settings.validate_session") diff --git a/tests/cli/commands/test_connection_command.py b/tests/cli/commands/test_connection_command.py index c21bf8b09eca5..e7328a77e90d8 100644 --- a/tests/cli/commands/test_connection_command.py +++ b/tests/cli/commands/test_connection_command.py @@ -35,6 +35,8 @@ from airflow.utils.session import create_session, provide_session from tests.test_utils.db import clear_db_connections +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module", autouse=True) def clear_connections(): diff --git a/tests/cli/commands/test_dag_command.py b/tests/cli/commands/test_dag_command.py index 0e4a5490b6de3..e148808dae438 100644 --- a/tests/cli/commands/test_dag_command.py +++ b/tests/cli/commands/test_dag_command.py @@ -51,6 +51,8 @@ # TODO: Check if tests needs side effects - locally there's missing DAG +pytestmark = pytest.mark.db_test + class TestCliDags: @classmethod diff --git a/tests/cli/commands/test_dag_processor_command.py b/tests/cli/commands/test_dag_processor_command.py index 0fb9dc6374052..59da9efbb9684 100644 --- a/tests/cli/commands/test_dag_processor_command.py +++ b/tests/cli/commands/test_dag_processor_command.py @@ -26,6 +26,8 @@ from airflow.configuration import conf from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestDagProcessorCommand: """ diff --git a/tests/cli/commands/test_db_command.py b/tests/cli/commands/test_db_command.py index b9809eaeba1f2..60fd9ed7a0745 100644 --- a/tests/cli/commands/test_db_command.py +++ b/tests/cli/commands/test_db_command.py @@ -28,6 +28,8 @@ from airflow.cli.commands import db_command from airflow.exceptions import AirflowException +pytestmark = pytest.mark.db_test + class TestCliDb: @classmethod diff --git a/tests/cli/commands/test_info_command.py b/tests/cli/commands/test_info_command.py index 88d37bc1b3298..74426f1225d23 100644 --- a/tests/cli/commands/test_info_command.py +++ b/tests/cli/commands/test_info_command.py @@ -141,6 +141,7 @@ def test_tools_info(self): } assert self.unique_items(instance._tools_info) == expected + @pytest.mark.db_test @conf_vars( { ("database", "sql_alchemy_conn"): "postgresql+psycopg2://postgres:airflow@postgres/airflow", @@ -154,6 +155,7 @@ def test_show_info(self): assert airflow_version in output assert "postgresql+psycopg2://postgres:airflow@postgres/airflow" in output + @pytest.mark.db_test @conf_vars( { ("database", "sql_alchemy_conn"): "postgresql+psycopg2://postgres:airflow@postgres/airflow", diff --git a/tests/cli/commands/test_internal_api_command.py b/tests/cli/commands/test_internal_api_command.py index 76ab4237ac4e8..f3940278a4b6d 100644 --- a/tests/cli/commands/test_internal_api_command.py +++ b/tests/cli/commands/test_internal_api_command.py @@ -82,6 +82,7 @@ def test_ready_prefix_on_cmdline_dead_process(self): assert self.monitor._get_num_ready_workers_running() == 0 +@pytest.mark.db_test @pytest.mark.skipif(not _ENABLE_AIP_44, reason="AIP-44 is disabled") class TestCliInternalAPI(_ComonCLIGunicornTestClass): main_process_regexp = r"airflow internal-api" diff --git a/tests/cli/commands/test_jobs_command.py b/tests/cli/commands/test_jobs_command.py index 32e74a4f8a347..bd58f0219e4ba 100644 --- a/tests/cli/commands/test_jobs_command.py +++ b/tests/cli/commands/test_jobs_command.py @@ -30,6 +30,7 @@ from tests.test_utils.db import clear_db_jobs +@pytest.mark.db_test class TestCliConfigList: @classmethod def setup_class(cls): diff --git a/tests/cli/commands/test_kerberos_command.py b/tests/cli/commands/test_kerberos_command.py index 8835d9d287305..2c23ac608310c 100644 --- a/tests/cli/commands/test_kerberos_command.py +++ b/tests/cli/commands/test_kerberos_command.py @@ -18,11 +18,15 @@ from unittest import mock +import pytest + from airflow.cli import cli_parser from airflow.cli.commands import kerberos_command from airflow.security.kerberos import KerberosMode from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestKerberosCommand: @classmethod diff --git a/tests/cli/commands/test_kubernetes_command.py b/tests/cli/commands/test_kubernetes_command.py index 5f42b0cc6311c..601990825c3d9 100644 --- a/tests/cli/commands/test_kubernetes_command.py +++ b/tests/cli/commands/test_kubernetes_command.py @@ -22,12 +22,15 @@ from unittest.mock import MagicMock, call import kubernetes +import pytest from dateutil.parser import parse from airflow.cli import cli_parser from airflow.cli.commands import kubernetes_command from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestGenerateDagYamlCommand: @classmethod diff --git a/tests/cli/commands/test_pool_command.py b/tests/cli/commands/test_pool_command.py index 978ecb5422438..67cc39dec4cab 100644 --- a/tests/cli/commands/test_pool_command.py +++ b/tests/cli/commands/test_pool_command.py @@ -30,6 +30,8 @@ from airflow.settings import Session from airflow.utils.db import add_default_pool_if_not_exists +pytestmark = pytest.mark.db_test + class TestCliPools: @classmethod diff --git a/tests/cli/commands/test_rotate_fernet_key_command.py b/tests/cli/commands/test_rotate_fernet_key_command.py index 82c672160fd24..fe38b22b731f5 100644 --- a/tests/cli/commands/test_rotate_fernet_key_command.py +++ b/tests/cli/commands/test_rotate_fernet_key_command.py @@ -18,6 +18,7 @@ from unittest import mock +import pytest from cryptography.fernet import Fernet from airflow.cli import cli_parser @@ -28,6 +29,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_connections, clear_db_variables +pytestmark = pytest.mark.db_test + class TestRotateFernetKeyCommand: @classmethod diff --git a/tests/cli/commands/test_scheduler_command.py b/tests/cli/commands/test_scheduler_command.py index 1b66cc7b85e19..9d67e4d512cbb 100644 --- a/tests/cli/commands/test_scheduler_command.py +++ b/tests/cli/commands/test_scheduler_command.py @@ -29,6 +29,8 @@ from airflow.utils.serve_logs import serve_logs from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestSchedulerCommand: @classmethod diff --git a/tests/cli/commands/test_task_command.py b/tests/cli/commands/test_task_command.py index 85f5ec9d47b61..0e86f20f2e400 100644 --- a/tests/cli/commands/test_task_command.py +++ b/tests/cli/commands/test_task_command.py @@ -53,6 +53,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_pools, clear_db_runs +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from airflow.models.dag import DAG diff --git a/tests/cli/commands/test_triggerer_command.py b/tests/cli/commands/test_triggerer_command.py index 387437db3b3bb..abfba226758ac 100644 --- a/tests/cli/commands/test_triggerer_command.py +++ b/tests/cli/commands/test_triggerer_command.py @@ -19,9 +19,13 @@ from unittest import mock +import pytest + from airflow.cli import cli_parser from airflow.cli.commands import triggerer_command +pytestmark = pytest.mark.db_test + class TestTriggererCommand: """ diff --git a/tests/cli/commands/test_variable_command.py b/tests/cli/commands/test_variable_command.py index 7e0086ad95ad3..4a986c589ee9c 100644 --- a/tests/cli/commands/test_variable_command.py +++ b/tests/cli/commands/test_variable_command.py @@ -31,6 +31,8 @@ from airflow.utils.session import create_session from tests.test_utils.db import clear_db_variables +pytestmark = pytest.mark.db_test + class TestCliVariables: @classmethod diff --git a/tests/cli/commands/test_webserver_command.py b/tests/cli/commands/test_webserver_command.py index 34ff2f0be44bc..2122c508f04a6 100644 --- a/tests/cli/commands/test_webserver_command.py +++ b/tests/cli/commands/test_webserver_command.py @@ -226,6 +226,7 @@ def test_ready_prefix_on_cmdline_dead_process(self): assert self.monitor._get_num_ready_workers_running() == 0 +@pytest.mark.db_test class TestCliWebServer(_ComonCLIGunicornTestClass): main_process_regexp = r"airflow webserver" diff --git a/tests/cli/test_cli_parser.py b/tests/cli/test_cli_parser.py index 115c581cccdd4..af7edba325a25 100644 --- a/tests/cli/test_cli_parser.py +++ b/tests/cli/test_cli_parser.py @@ -135,6 +135,7 @@ def test_subcommand_arg_flag_conflict(self): f"short option flags {conflict_short_option}" ) + @pytest.mark.db_test @patch.object(LocalExecutor, "get_cli_commands") def test_dynamic_conflict_detection(self, cli_commands_mock: MagicMock): core_commands.append( diff --git a/tests/conftest.py b/tests/conftest.py index f3a4c2df73195..1eafbd7e15a1a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -284,6 +284,14 @@ def pytest_configure(config): config.addinivalue_line( "markers", "need_serialized_dag: mark tests that require dags in serialized form to be present" ) + config.addinivalue_line( + "markers", + "db_test: mark tests that require database to be present", + ) + config.addinivalue_line( + "markers", + "non_db_test_override: you can mark individual tests with this marker to override the db_test marker", + ) os.environ["_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK"] = "1" diff --git a/tests/core/test_core.py b/tests/core/test_core.py index bf01e09f497d3..5f37cb2db01c6 100644 --- a/tests/core/test_core.py +++ b/tests/core/test_core.py @@ -34,6 +34,8 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_db_task_fail +pytestmark = pytest.mark.db_test + DEFAULT_DATE = datetime(2015, 1, 1) diff --git a/tests/core/test_impersonation_tests.py b/tests/core/test_impersonation_tests.py index b92d437f1608f..07a3d71d400f6 100644 --- a/tests/core/test_impersonation_tests.py +++ b/tests/core/test_impersonation_tests.py @@ -37,6 +37,8 @@ from airflow.utils.types import DagRunType from tests.test_utils import db +pytestmark = pytest.mark.db_test + DEV_NULL = "/dev/null" TEST_ROOT_FOLDER = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) TEST_DAG_FOLDER = os.path.join(TEST_ROOT_FOLDER, "dags") diff --git a/tests/core/test_sentry.py b/tests/core/test_sentry.py index 085fde8a810e9..10c88675ea265 100644 --- a/tests/core/test_sentry.py +++ b/tests/core/test_sentry.py @@ -141,6 +141,7 @@ def sentry_minimum(self): importlib.reload(sentry) + @pytest.mark.db_test def test_add_tagging(self, sentry, task_instance): """ Test adding tags. @@ -150,6 +151,7 @@ def test_add_tagging(self, sentry, task_instance): for key, value in scope._tags.items(): assert TEST_SCOPE[key] == value + @pytest.mark.db_test @time_machine.travel(CRUMB_DATE) def test_add_breadcrumbs(self, sentry, task_instance): """ diff --git a/tests/core/test_sqlalchemy_config.py b/tests/core/test_sqlalchemy_config.py index 9abcc1991dcc6..b75c70fe248de 100644 --- a/tests/core/test_sqlalchemy_config.py +++ b/tests/core/test_sqlalchemy_config.py @@ -28,6 +28,8 @@ SQL_ALCHEMY_CONNECT_ARGS = {"test": 43503, "dict": {"is": 1, "supported": "too"}} +pytestmark = pytest.mark.db_test + class TestSqlAlchemySettings: def setup_method(self): diff --git a/tests/dag_processing/test_job_runner.py b/tests/dag_processing/test_job_runner.py index d5135afd5c7b6..8edede91a3c88 100644 --- a/tests/dag_processing/test_job_runner.py +++ b/tests/dag_processing/test_job_runner.py @@ -63,6 +63,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_callbacks, clear_db_dags, clear_db_runs, clear_db_serialized_dags +pytestmark = pytest.mark.db_test + + TEST_DAG_FOLDER = pathlib.Path(__file__).parents[1].resolve() / "dags" DEFAULT_DATE = timezone.datetime(2016, 1, 1) diff --git a/tests/dag_processing/test_processor.py b/tests/dag_processing/test_processor.py index 5d3a4cbd30a34..ac94edc510e98 100644 --- a/tests/dag_processing/test_processor.py +++ b/tests/dag_processing/test_processor.py @@ -50,6 +50,8 @@ ) from tests.test_utils.mock_executor import MockExecutor +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) # Include the words "airflow" and "dag" in the file contents, diff --git a/tests/dags/test_clear_subdag.py b/tests/dags/test_clear_subdag.py index c291fca5cca7e..7375b2bdf9d7f 100644 --- a/tests/dags/test_clear_subdag.py +++ b/tests/dags/test_clear_subdag.py @@ -19,10 +19,14 @@ import datetime import warnings +import pytest + from airflow.models.dag import DAG from airflow.operators.bash import BashOperator from airflow.operators.subdag import SubDagOperator +pytestmark = pytest.mark.db_test + def create_subdag_opt(main_dag): subdag_name = "daily_job" diff --git a/tests/datasets/test_manager.py b/tests/datasets/test_manager.py index a5abc764a9488..19b6b1ed454d4 100644 --- a/tests/datasets/test_manager.py +++ b/tests/datasets/test_manager.py @@ -27,6 +27,8 @@ from airflow.models.dag import DagModel from airflow.models.dataset import DagScheduleDatasetReference, DatasetDagRunQueue, DatasetEvent, DatasetModel +pytestmark = pytest.mark.db_test + @pytest.fixture() def mock_task_instance(): diff --git a/tests/decorators/test_branch_external_python.py b/tests/decorators/test_branch_external_python.py index 01e1f9b9683ec..ca62e038f1ea5 100644 --- a/tests/decorators/test_branch_external_python.py +++ b/tests/decorators/test_branch_external_python.py @@ -24,6 +24,8 @@ from airflow.decorators import task from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class Test_BranchPythonDecoratedOperator: @pytest.mark.parametrize("branch_task_name", ["task_1", "task_2"]) diff --git a/tests/decorators/test_branch_python.py b/tests/decorators/test_branch_python.py index b8368722dd446..8bbec6076b8ef 100644 --- a/tests/decorators/test_branch_python.py +++ b/tests/decorators/test_branch_python.py @@ -22,6 +22,8 @@ from airflow.decorators import task from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class Test_BranchPythonDecoratedOperator: @pytest.mark.parametrize("branch_task_name", ["task_1", "task_2"]) diff --git a/tests/decorators/test_branch_virtualenv.py b/tests/decorators/test_branch_virtualenv.py index 861ba154af177..66f539ca4c988 100644 --- a/tests/decorators/test_branch_virtualenv.py +++ b/tests/decorators/test_branch_virtualenv.py @@ -22,6 +22,8 @@ from airflow.decorators import task from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class Test_BranchPythonDecoratedOperator: @pytest.mark.parametrize("branch_task_name", ["task_1", "task_2"]) diff --git a/tests/decorators/test_external_python.py b/tests/decorators/test_external_python.py index 80a952e679890..cdd8c6cd49de0 100644 --- a/tests/decorators/test_external_python.py +++ b/tests/decorators/test_external_python.py @@ -30,6 +30,9 @@ from airflow.decorators import setup, task, teardown from airflow.utils import timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2016, 1, 1) END_DATE = timezone.datetime(2016, 1, 2) INTERVAL = timedelta(hours=12) diff --git a/tests/decorators/test_python.py b/tests/decorators/test_python.py index 23cb62bc1c9fb..78203ca6efeba 100644 --- a/tests/decorators/test_python.py +++ b/tests/decorators/test_python.py @@ -42,6 +42,9 @@ from airflow.utils.xcom import XCOM_RETURN_KEY from tests.operators.test_python import BasePythonTest +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from airflow.models.dagrun import DagRun diff --git a/tests/decorators/test_python_virtualenv.py b/tests/decorators/test_python_virtualenv.py index 96b76236561a4..fc604ac4643a8 100644 --- a/tests/decorators/test_python_virtualenv.py +++ b/tests/decorators/test_python_virtualenv.py @@ -26,6 +26,8 @@ from airflow.decorators import setup, task, teardown from airflow.utils import timezone +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) PYTHON_VERSION = sys.version_info[0] diff --git a/tests/decorators/test_sensor.py b/tests/decorators/test_sensor.py index a6dd9106cf38d..77852f34f7262 100644 --- a/tests/decorators/test_sensor.py +++ b/tests/decorators/test_sensor.py @@ -26,6 +26,8 @@ from airflow.sensors.base import PokeReturnValue from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class TestSensorDecorator: def test_sensor_fails_on_none_python_callable(self, dag_maker): diff --git a/tests/decorators/test_setup_teardown.py b/tests/decorators/test_setup_teardown.py index f654ff0372667..80694f47cba75 100644 --- a/tests/decorators/test_setup_teardown.py +++ b/tests/decorators/test_setup_teardown.py @@ -24,6 +24,8 @@ from airflow.exceptions import AirflowException from airflow.operators.bash import BashOperator +pytestmark = pytest.mark.db_test + def make_task(name, type_, setup_=False, teardown_=False): if type_ == "classic" and setup_: diff --git a/tests/decorators/test_short_circuit.py b/tests/decorators/test_short_circuit.py index 27240c69b8fb5..f5ad68bdeac79 100644 --- a/tests/decorators/test_short_circuit.py +++ b/tests/decorators/test_short_circuit.py @@ -17,12 +17,16 @@ # under the License. from __future__ import annotations +import pytest from pendulum import datetime from airflow.decorators import task from airflow.utils.state import State from airflow.utils.trigger_rule import TriggerRule +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2022, 8, 17) diff --git a/tests/decorators/test_task_group.py b/tests/decorators/test_task_group.py index 632782c54e391..20f1f0e60ee3d 100644 --- a/tests/decorators/test_task_group.py +++ b/tests/decorators/test_task_group.py @@ -191,6 +191,7 @@ def tg(a, b): assert saved == {"a": 1, "b": MappedArgument(input=tg._expand_input, key="b")} +@pytest.mark.db_test def test_task_group_expand_kwargs_with_upstream(dag_maker, session, caplog): with dag_maker() as dag: @@ -214,6 +215,7 @@ def t2(): assert "missing upstream values: ['expand_kwargs() argument']" not in caplog.text +@pytest.mark.db_test def test_task_group_expand_with_upstream(dag_maker, session, caplog): with dag_maker() as dag: diff --git a/tests/executors/test_base_executor.py b/tests/executors/test_base_executor.py index 7c21949b53d25..b2568e9a0a7a5 100644 --- a/tests/executors/test_base_executor.py +++ b/tests/executors/test_base_executor.py @@ -111,6 +111,7 @@ def setup_dagrun(dag_maker): return dag_maker.create_dagrun(execution_date=date) +@pytest.mark.db_test def test_try_adopt_task_instances(dag_maker): dagrun = setup_dagrun(dag_maker) tis = dagrun.task_instances @@ -131,6 +132,7 @@ def setup_trigger_tasks(dag_maker): return executor, dagrun +@pytest.mark.db_test @pytest.mark.parametrize("open_slots", [1, 2, 3]) def test_trigger_queued_tasks(dag_maker, open_slots): executor, _ = setup_trigger_tasks(dag_maker) @@ -138,6 +140,7 @@ def test_trigger_queued_tasks(dag_maker, open_slots): assert executor.execute_async.call_count == open_slots +@pytest.mark.db_test @pytest.mark.parametrize( "can_try_num, change_state_num, second_exec", [ @@ -197,6 +200,7 @@ def test_trigger_running_tasks(can_try_mock, dag_maker, can_try_num, change_stat assert executor.execute_async.call_count == expected_calls +@pytest.mark.db_test def test_validate_airflow_tasks_run_command(dag_maker): dagrun = setup_dagrun(dag_maker) tis = dagrun.task_instances diff --git a/tests/executors/test_executor_loader.py b/tests/executors/test_executor_loader.py index a28c5e4566fb6..fa1691cc2beea 100644 --- a/tests/executors/test_executor_loader.py +++ b/tests/executors/test_executor_loader.py @@ -110,12 +110,14 @@ def test_should_support_import_custom_path(self): assert "FakeExecutor" == executor.__name__ assert import_source == ConnectorSource.CUSTOM_PATH + @pytest.mark.db_test @pytest.mark.backend("mssql", "mysql", "postgres") @pytest.mark.parametrize("executor", [FakeExecutor, FakeSingleThreadedExecutor]) def test_validate_database_executor_compatibility_general(self, monkeypatch, executor): monkeypatch.delenv("_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK") ExecutorLoader.validate_database_executor_compatibility(executor) + @pytest.mark.db_test @pytest.mark.backend("sqlite") @pytest.mark.parametrize( ["executor", "expectation"], diff --git a/tests/executors/test_local_executor.py b/tests/executors/test_local_executor.py index d17f9928f2da5..c49c3f48f5c55 100644 --- a/tests/executors/test_local_executor.py +++ b/tests/executors/test_local_executor.py @@ -21,11 +21,15 @@ import subprocess from unittest import mock +import pytest + from airflow import settings from airflow.exceptions import AirflowException from airflow.executors.local_executor import LocalExecutor from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class TestLocalExecutor: TEST_SUCCESS_COMMANDS = 5 diff --git a/tests/jobs/test_backfill_job.py b/tests/jobs/test_backfill_job.py index 195a959ee9b1c..a62700a47bb9b 100644 --- a/tests/jobs/test_backfill_job.py +++ b/tests/jobs/test_backfill_job.py @@ -66,6 +66,8 @@ from tests.test_utils.mock_executor import MockExecutor from tests.test_utils.timetables import cron_timetable +pytestmark = pytest.mark.db_test + logger = logging.getLogger(__name__) DEFAULT_DATE = timezone.datetime(2016, 1, 1) diff --git a/tests/jobs/test_base_job.py b/tests/jobs/test_base_job.py index 04f761fa67a37..8f7237ffc6871 100644 --- a/tests/jobs/test_base_job.py +++ b/tests/jobs/test_base_job.py @@ -34,6 +34,8 @@ from tests.test_utils.config import conf_vars from tests.utils.test_helpers import MockJobRunner, SchedulerJobRunner, TriggererJobRunner +pytestmark = pytest.mark.db_test + class TestJob: def test_state_success(self): diff --git a/tests/jobs/test_local_task_job.py b/tests/jobs/test_local_task_job.py index 7d8b18a26b18d..9a9a1eeacd75b 100644 --- a/tests/jobs/test_local_task_job.py +++ b/tests/jobs/test_local_task_job.py @@ -57,6 +57,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.mock_executor import MockExecutor +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) TEST_DAG_FOLDER = os.environ["AIRFLOW__CORE__DAGS_FOLDER"] diff --git a/tests/jobs/test_scheduler_job.py b/tests/jobs/test_scheduler_job.py index 43cf0dc282377..356de8b448740 100644 --- a/tests/jobs/test_scheduler_job.py +++ b/tests/jobs/test_scheduler_job.py @@ -83,6 +83,8 @@ from tests.test_utils.mock_operators import CustomOperator from tests.utils.test_timezone import UTC +pytestmark = pytest.mark.db_test + ROOT_FOLDER = os.path.realpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir) ) diff --git a/tests/jobs/test_triggerer_job.py b/tests/jobs/test_triggerer_job.py index 49eec8ee2aec4..ee6e4b4c056b0 100644 --- a/tests/jobs/test_triggerer_job.py +++ b/tests/jobs/test_triggerer_job.py @@ -48,6 +48,8 @@ from tests.core.test_logging_config import reset_logging from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + class TimeDeltaTrigger_(TimeDeltaTrigger): def __init__(self, delta, filename): diff --git a/tests/lineage/test_lineage.py b/tests/lineage/test_lineage.py index 2fbe75ae1f53d..6e843f8ff686a 100644 --- a/tests/lineage/test_lineage.py +++ b/tests/lineage/test_lineage.py @@ -20,6 +20,7 @@ from unittest import mock import attr +import pytest from airflow.lineage import AUTO, apply_lineage, get_backend, prepare_lineage from airflow.lineage.backend import LineageBackend @@ -31,6 +32,9 @@ from airflow.utils.types import DagRunType from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2016, 1, 1) diff --git a/tests/listeners/test_listeners.py b/tests/listeners/test_listeners.py index 2ec6c4e45a214..ab37689739cd4 100644 --- a/tests/listeners/test_listeners.py +++ b/tests/listeners/test_listeners.py @@ -37,6 +37,9 @@ ) from tests.utils.test_helpers import MockJobRunner +pytestmark = pytest.mark.db_test + + LISTENERS = [ class_listener, full_listener, diff --git a/tests/models/test_base.py b/tests/models/test_base.py index 8afe421817ee7..d85eda6dd2510 100644 --- a/tests/models/test_base.py +++ b/tests/models/test_base.py @@ -21,6 +21,8 @@ from airflow.models.base import get_id_collation_args from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + @pytest.mark.parametrize( ("dsn", "expected", "extra"), diff --git a/tests/models/test_baseoperator.py b/tests/models/test_baseoperator.py index e136dd15e089e..793a31b465327 100644 --- a/tests/models/test_baseoperator.py +++ b/tests/models/test_baseoperator.py @@ -211,6 +211,7 @@ def test_trigger_rule_validation(self): task_id="test_invalid_trigger_rule", dag=fail_stop_dag, trigger_rule=TriggerRule.DUMMY ) + @pytest.mark.db_test @pytest.mark.parametrize( ("content", "context", "expected_output"), [ @@ -354,6 +355,7 @@ def print_val(x): print_val.expand(x=task1) + @pytest.mark.db_test def test_render_template_fields(self): """Verify if operator attributes are correctly templated.""" task = MockOperator(task_id="op1", arg1="{{ foo }}", arg2="{{ bar }}") @@ -375,6 +377,7 @@ def test_render_template_fields_no_change(self, content): result = task.render_template(content, {"foo": "bar"}) assert content is result + @pytest.mark.db_test def test_nested_template_fields_declared_must_exist(self): """Test render_template when a nested template field is missing.""" task = BaseOperator(task_id="op1") @@ -415,6 +418,7 @@ def test_jinja_invalid_expression_is_just_propagated(self): with pytest.raises(jinja2.exceptions.TemplateSyntaxError): task.render_template("{{ invalid expression }}", {}) + @pytest.mark.db_test @mock.patch("airflow.templates.SandboxedEnvironment", autospec=True) def test_jinja_env_creation(self, mock_jinja_env): """Verify if a Jinja environment is created only once when templating.""" @@ -819,6 +823,7 @@ class ConcreteSubclassOp(InitSubclassOp, class_arg=class_arg): assert task_copy.context_arg == context +@pytest.mark.db_test def test_operator_retries_invalid(dag_maker): with pytest.raises(AirflowException) as ctx: with dag_maker(): @@ -826,6 +831,7 @@ def test_operator_retries_invalid(dag_maker): assert str(ctx.value) == "'retries' type must be int, not str" +@pytest.mark.db_test @pytest.mark.parametrize( ("retries", "expected"), [ @@ -854,6 +860,7 @@ def test_operator_retries(caplog, dag_maker, retries, expected): assert caplog.record_tuples == expected +@pytest.mark.db_test def test_default_retry_delay(dag_maker): with dag_maker(dag_id="test_default_retry_delay"): task1 = BaseOperator(task_id="test_no_explicit_retry_delay") @@ -861,6 +868,7 @@ def test_default_retry_delay(dag_maker): assert task1.retry_delay == timedelta(seconds=300) +@pytest.mark.db_test def test_dag_level_retry_delay(dag_maker): with dag_maker(dag_id="test_dag_level_retry_delay", default_args={"retry_delay": timedelta(seconds=100)}): task1 = BaseOperator(task_id="test_no_explicit_retry_delay") @@ -868,6 +876,7 @@ def test_dag_level_retry_delay(dag_maker): assert task1.retry_delay == timedelta(seconds=100) +@pytest.mark.db_test def test_task_level_retry_delay(dag_maker): with dag_maker( dag_id="test_task_level_retry_delay", default_args={"retry_delay": timedelta(seconds=100)} @@ -889,6 +898,7 @@ def task0(): copy.deepcopy(dag) +@pytest.mark.db_test @pytest.mark.parametrize( ("task", "context", "expected_exception", "expected_rendering", "expected_log", "not_expected_log"), [ @@ -945,6 +955,7 @@ def _do_render(): assert not_expected_log not in caplog.text +@pytest.mark.db_test def test_find_mapped_dependants_in_another_group(dag_maker): from airflow.utils.task_group import TaskGroup @@ -986,6 +997,7 @@ def get_states(dr): return dict(ti_dict) +@pytest.mark.db_test def test_teardown_and_fail_stop(dag_maker): """ when fail_stop enabled, teardowns should run according to their setups. @@ -1030,6 +1042,7 @@ def my_teardown(): assert states == expected +@pytest.mark.db_test def test_get_task_instances(session): import pendulum diff --git a/tests/models/test_cleartasks.py b/tests/models/test_cleartasks.py index 2f45a57707333..ed0232926aede 100644 --- a/tests/models/test_cleartasks.py +++ b/tests/models/test_cleartasks.py @@ -35,6 +35,8 @@ from tests.models import DEFAULT_DATE from tests.test_utils import db +pytestmark = pytest.mark.db_test + class TestClearTasks: @pytest.fixture(autouse=True, scope="class") diff --git a/tests/models/test_dag.py b/tests/models/test_dag.py index d063077fa25dc..9fa0eb669d11b 100644 --- a/tests/models/test_dag.py +++ b/tests/models/test_dag.py @@ -93,6 +93,8 @@ from tests.test_utils.mapping import expand_mapped_task from tests.test_utils.timetables import cron_timetable, delta_timetable +pytestmark = pytest.mark.db_test + TEST_DATE = datetime_tz(2015, 1, 2, 0, 0) repo_root = Path(__file__).parents[2] diff --git a/tests/models/test_dagbag.py b/tests/models/test_dagbag.py index 8ebff1dc16e32..0004fb608f36b 100644 --- a/tests/models/test_dagbag.py +++ b/tests/models/test_dagbag.py @@ -50,6 +50,8 @@ from tests.test_utils.asserts import assert_queries_count from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + example_dags_folder = pathlib.Path(airflow.example_dags.__path__[0]) # type: ignore[attr-defined] diff --git a/tests/models/test_dagcode.py b/tests/models/test_dagcode.py index 07a952d23cfbf..df85a8808e565 100644 --- a/tests/models/test_dagcode.py +++ b/tests/models/test_dagcode.py @@ -32,6 +32,8 @@ from airflow.utils.session import create_session from tests.test_utils.db import clear_db_dag_code +pytestmark = pytest.mark.db_test + def make_example_dags(module): """Loads DAGs from a module for test.""" diff --git a/tests/models/test_dagrun.py b/tests/models/test_dagrun.py index 50a54783ffaaa..5732e0d565576 100644 --- a/tests/models/test_dagrun.py +++ b/tests/models/test_dagrun.py @@ -50,6 +50,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.mock_operators import MockOperator +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from sqlalchemy.orm.session import Session diff --git a/tests/models/test_dagwarning.py b/tests/models/test_dagwarning.py index 06b14b56eaf59..58d6e5c752c64 100644 --- a/tests/models/test_dagwarning.py +++ b/tests/models/test_dagwarning.py @@ -20,12 +20,15 @@ from unittest import mock from unittest.mock import MagicMock +import pytest from sqlalchemy.exc import OperationalError from airflow.models import DagModel from airflow.models.dagwarning import DagWarning from tests.test_utils.db import clear_db_dags +pytestmark = pytest.mark.db_test + class TestDagWarning: def setup_method(self): diff --git a/tests/models/test_mappedoperator.py b/tests/models/test_mappedoperator.py index 3155039ceb50b..7244c55774840 100644 --- a/tests/models/test_mappedoperator.py +++ b/tests/models/test_mappedoperator.py @@ -46,6 +46,8 @@ from tests.test_utils.mapping import expand_mapped_task from tests.test_utils.mock_operators import MockOperator, MockOperatorWithNestedFields, NestedFields +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from airflow.utils.context import Context diff --git a/tests/models/test_param.py b/tests/models/test_param.py index c31e7a5abf016..24a910f01e7a6 100644 --- a/tests/models/test_param.py +++ b/tests/models/test_param.py @@ -323,6 +323,7 @@ def setup_class(self): def teardown_method(self): self.clean_db() + @pytest.mark.db_test def test_dag_param_resolves(self, dag_maker): """Test dagparam resolves on operator execution""" with dag_maker(dag_id="test_xcom_pass_to_op") as dag: @@ -344,6 +345,7 @@ def return_num(num): ti = dr.get_task_instances()[0] assert ti.xcom_pull() == self.VALUE + @pytest.mark.db_test def test_dag_param_overwrite(self, dag_maker): """Test dag param is overwritten from dagrun config""" with dag_maker(dag_id="test_xcom_pass_to_op") as dag: @@ -368,6 +370,7 @@ def return_num(num): ti = dr.get_task_instances()[0] assert ti.xcom_pull() == new_value + @pytest.mark.db_test def test_dag_param_default(self, dag_maker): """Test dag param is retrieved from default config""" with dag_maker(dag_id="test_xcom_pass_to_op", params={"value": "test"}) as dag: @@ -386,6 +389,7 @@ def return_num(num): ti = dr.get_task_instances()[0] assert ti.xcom_pull() == "test" + @pytest.mark.db_test @pytest.mark.parametrize( "default, should_warn", [ diff --git a/tests/models/test_pool.py b/tests/models/test_pool.py index 6bce35db2a302..a158b35c6f26c 100644 --- a/tests/models/test_pool.py +++ b/tests/models/test_pool.py @@ -29,6 +29,8 @@ from airflow.utils.state import State from tests.test_utils.db import clear_db_dags, clear_db_pools, clear_db_runs, set_default_pool_slots +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) diff --git a/tests/models/test_renderedtifields.py b/tests/models/test_renderedtifields.py index 12fc108ce0124..91b98b58edd5e 100644 --- a/tests/models/test_renderedtifields.py +++ b/tests/models/test_renderedtifields.py @@ -34,6 +34,9 @@ from tests.test_utils.asserts import assert_queries_count from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_rendered_ti_fields +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2018, 1, 1) EXECUTION_DATE = datetime(2019, 1, 1) diff --git a/tests/models/test_serialized_dag.py b/tests/models/test_serialized_dag.py index eec8ec7cbf308..1967c74f1a25a 100644 --- a/tests/models/test_serialized_dag.py +++ b/tests/models/test_serialized_dag.py @@ -37,6 +37,8 @@ from tests.test_utils import db from tests.test_utils.asserts import assert_queries_count +pytestmark = pytest.mark.db_test + # To move it to a shared module. def make_example_dags(module): diff --git a/tests/models/test_skipmixin.py b/tests/models/test_skipmixin.py index 103abc3ef67f6..2e4f8ad0d84f0 100644 --- a/tests/models/test_skipmixin.py +++ b/tests/models/test_skipmixin.py @@ -34,6 +34,9 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2016, 1, 1) diff --git a/tests/models/test_taskinstance.py b/tests/models/test_taskinstance.py index 27ff39763fe2e..39b6a147d9383 100644 --- a/tests/models/test_taskinstance.py +++ b/tests/models/test_taskinstance.py @@ -97,6 +97,8 @@ from tests.test_utils.db import clear_db_connections, clear_db_runs from tests.test_utils.mock_operators import MockOperator +pytestmark = pytest.mark.db_test + @pytest.fixture def test_pool(): diff --git a/tests/models/test_taskmixin.py b/tests/models/test_taskmixin.py index 2435d6711a763..c34d46fd4ea5d 100644 --- a/tests/models/test_taskmixin.py +++ b/tests/models/test_taskmixin.py @@ -24,6 +24,8 @@ from airflow.decorators import setup, task, teardown from airflow.models.baseoperator import BaseOperator +pytestmark = pytest.mark.db_test + def cleared_tasks(dag, task_id): dag_ = dag.partial_subset(task_id, include_downstream=True, include_upstream=False) diff --git a/tests/models/test_timestamp.py b/tests/models/test_timestamp.py index 2315e25dd4de7..bda4306498eac 100644 --- a/tests/models/test_timestamp.py +++ b/tests/models/test_timestamp.py @@ -27,6 +27,8 @@ from airflow.utils.state import State from tests.test_utils.db import clear_db_dags, clear_db_logs, clear_db_runs +pytestmark = pytest.mark.db_test + @pytest.fixture(autouse=True) def clear_db(): diff --git a/tests/models/test_trigger.py b/tests/models/test_trigger.py index 3626c946707c9..8463edf831b02 100644 --- a/tests/models/test_trigger.py +++ b/tests/models/test_trigger.py @@ -30,6 +30,8 @@ from airflow.utils.session import create_session from airflow.utils.state import State +pytestmark = pytest.mark.db_test + @pytest.fixture def session(): diff --git a/tests/models/test_variable.py b/tests/models/test_variable.py index caf40b8da9965..c5d712312c2fa 100644 --- a/tests/models/test_variable.py +++ b/tests/models/test_variable.py @@ -31,6 +31,8 @@ from tests.test_utils import db from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestVariable: @pytest.fixture(autouse=True) diff --git a/tests/models/test_xcom.py b/tests/models/test_xcom.py index 7d1a63d8e962c..db290c0e85644 100644 --- a/tests/models/test_xcom.py +++ b/tests/models/test_xcom.py @@ -37,6 +37,9 @@ from airflow.utils.xcom import XCOM_RETURN_KEY from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from sqlalchemy.orm import Session diff --git a/tests/models/test_xcom_arg.py b/tests/models/test_xcom_arg.py index 1f9a342c026d1..b04e9cf6c0d3a 100644 --- a/tests/models/test_xcom_arg.py +++ b/tests/models/test_xcom_arg.py @@ -25,6 +25,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + + VALUE = 42 diff --git a/tests/models/test_xcom_arg_map.py b/tests/models/test_xcom_arg_map.py index 5003010297ad1..526a862cd2a7e 100644 --- a/tests/models/test_xcom_arg_map.py +++ b/tests/models/test_xcom_arg_map.py @@ -23,6 +23,8 @@ from airflow.utils.state import TaskInstanceState from airflow.utils.trigger_rule import TriggerRule +pytestmark = pytest.mark.db_test + def test_xcom_map(dag_maker, session): results = set() diff --git a/tests/notifications/test_basenotifier.py b/tests/notifications/test_basenotifier.py index 289005345ea8b..65bda6ade8ade 100644 --- a/tests/notifications/test_basenotifier.py +++ b/tests/notifications/test_basenotifier.py @@ -26,6 +26,9 @@ from airflow.notifications.basenotifier import BaseNotifier from airflow.operators.empty import EmptyOperator +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from airflow.utils.context import Context diff --git a/tests/operators/test_bash.py b/tests/operators/test_bash.py index d9645795c0958..351c6595bfe9a 100644 --- a/tests/operators/test_bash.py +++ b/tests/operators/test_bash.py @@ -38,6 +38,7 @@ class TestBashOperator: + @pytest.mark.db_test @pytest.mark.parametrize( "append_env,user_defined_env,expected_airflow_home", [ @@ -197,6 +198,7 @@ def test_bash_operator_multi_byte_output(self): ) op.execute(context={}) + @pytest.mark.db_test def test_bash_operator_kill(self, dag_maker): import psutil diff --git a/tests/operators/test_branch_operator.py b/tests/operators/test_branch_operator.py index 1bedfd7484432..0bb5e318a73f3 100644 --- a/tests/operators/test_branch_operator.py +++ b/tests/operators/test_branch_operator.py @@ -19,6 +19,8 @@ import datetime +import pytest + from airflow.models.dag import DAG from airflow.models.dagrun import DagRun from airflow.models.taskinstance import TaskInstance as TI @@ -29,6 +31,8 @@ from airflow.utils.state import State from airflow.utils.types import DagRunType +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) INTERVAL = datetime.timedelta(hours=12) diff --git a/tests/operators/test_datetime.py b/tests/operators/test_datetime.py index 32dbfdff1c05a..26ae3908ff20c 100644 --- a/tests/operators/test_datetime.py +++ b/tests/operators/test_datetime.py @@ -32,6 +32,8 @@ from airflow.utils.session import create_session from airflow.utils.state import State +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) INTERVAL = datetime.timedelta(hours=12) diff --git a/tests/operators/test_email.py b/tests/operators/test_email.py index a4a76a043c030..dabafef284b2e 100644 --- a/tests/operators/test_email.py +++ b/tests/operators/test_email.py @@ -20,11 +20,15 @@ import datetime from unittest import mock +import pytest + from airflow.models.dag import DAG from airflow.operators.email import EmailOperator from airflow.utils import timezone from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2016, 1, 1) END_DATE = timezone.datetime(2016, 1, 2) INTERVAL = datetime.timedelta(hours=12) diff --git a/tests/operators/test_generic_transfer.py b/tests/operators/test_generic_transfer.py index e7882f6e67664..d10dcf284659e 100644 --- a/tests/operators/test_generic_transfer.py +++ b/tests/operators/test_generic_transfer.py @@ -27,6 +27,8 @@ from airflow.providers.postgres.hooks.postgres import PostgresHook from airflow.utils import timezone +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2015, 1, 1) DEFAULT_DATE_ISO = DEFAULT_DATE.isoformat() DEFAULT_DATE_DS = DEFAULT_DATE_ISO[:10] diff --git a/tests/operators/test_latest_only_operator.py b/tests/operators/test_latest_only_operator.py index 8c0e3d0ae117f..390bc6070b8d7 100644 --- a/tests/operators/test_latest_only_operator.py +++ b/tests/operators/test_latest_only_operator.py @@ -19,6 +19,7 @@ import datetime +import pytest import time_machine from airflow import settings @@ -32,6 +33,9 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_runs, clear_db_xcom +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2016, 1, 1) END_DATE = timezone.datetime(2016, 1, 2) INTERVAL = datetime.timedelta(hours=12) diff --git a/tests/operators/test_python.py b/tests/operators/test_python.py index cb2fd16a45ae7..aae0b39571812 100644 --- a/tests/operators/test_python.py +++ b/tests/operators/test_python.py @@ -61,6 +61,9 @@ from tests.test_utils import AIRFLOW_MAIN_FOLDER from tests.test_utils.db import clear_db_runs +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from airflow.models.dagrun import DagRun diff --git a/tests/operators/test_subdag_operator.py b/tests/operators/test_subdag_operator.py index 30ea788ba5e5f..88bb701966a4a 100644 --- a/tests/operators/test_subdag_operator.py +++ b/tests/operators/test_subdag_operator.py @@ -35,6 +35,8 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_runs +pytestmark = pytest.mark.db_test + DEFAULT_DATE = datetime(2016, 1, 1) default_args = {"start_date": DEFAULT_DATE} diff --git a/tests/operators/test_trigger_dagrun.py b/tests/operators/test_trigger_dagrun.py index 3cc38db298aad..823d9510ffaca 100644 --- a/tests/operators/test_trigger_dagrun.py +++ b/tests/operators/test_trigger_dagrun.py @@ -38,6 +38,8 @@ from airflow.utils.state import State from airflow.utils.types import DagRunType +pytestmark = pytest.mark.db_test + DEFAULT_DATE = datetime(2019, 1, 1, tzinfo=timezone.utc) TEST_DAG_ID = "testdag" TRIGGERED_DAG_ID = "triggerdag" diff --git a/tests/operators/test_weekday.py b/tests/operators/test_weekday.py index 9c9c8fc83469c..d5f154c327b66 100644 --- a/tests/operators/test_weekday.py +++ b/tests/operators/test_weekday.py @@ -34,6 +34,8 @@ from airflow.utils.state import State from airflow.utils.weekday import WeekDay +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2020, 2, 5) # Wednesday INTERVAL = datetime.timedelta(hours=12) TEST_CASE_BRANCH_FOLLOW_TRUE = { diff --git a/tests/plugins/test_plugins_manager.py b/tests/plugins/test_plugins_manager.py index 3a6502b9e2f3b..9d2ca78c71f80 100644 --- a/tests/plugins/test_plugins_manager.py +++ b/tests/plugins/test_plugins_manager.py @@ -36,6 +36,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.mock_plugins import mock_plugin_manager +pytestmark = pytest.mark.db_test + importlib_metadata_string = "importlib_metadata" try: @@ -73,6 +75,7 @@ def clean_plugins(): get_listener_manager().clear() +@pytest.mark.db_test class TestPluginsRBAC: @pytest.fixture(autouse=True) def _set_attrs(self, app): @@ -143,6 +146,7 @@ def test_app_static_folder(self): assert AIRFLOW_SOURCES_ROOT / "airflow" / "www" / "static" == Path(self.app.static_folder).resolve() +@pytest.mark.db_test def test_flaskappbuilder_nomenu_views(): from tests.plugins.test_plugin import v_nomenu_appbuilder_package diff --git a/tests/providers/airbyte/hooks/test_airbyte.py b/tests/providers/airbyte/hooks/test_airbyte.py index 271b531822581..d4a954e2ade25 100644 --- a/tests/providers/airbyte/hooks/test_airbyte.py +++ b/tests/providers/airbyte/hooks/test_airbyte.py @@ -26,6 +26,8 @@ from airflow.providers.airbyte.hooks.airbyte import AirbyteHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestAirbyteHook: """ diff --git a/tests/providers/alibaba/cloud/log/test_oss_task_handler.py b/tests/providers/alibaba/cloud/log/test_oss_task_handler.py index 0d0348d8aa07a..3459f7f4a97e2 100644 --- a/tests/providers/alibaba/cloud/log/test_oss_task_handler.py +++ b/tests/providers/alibaba/cloud/log/test_oss_task_handler.py @@ -29,6 +29,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + OSS_TASK_HANDLER_STRING = "airflow.providers.alibaba.cloud.log.oss_task_handler.{}" MOCK_OSS_CONN_ID = "mock_id" MOCK_BUCKET_NAME = "mock_bucket_name" diff --git a/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py b/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py index 5fdbd310bbb70..8333de36a8abd 100644 --- a/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py +++ b/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py @@ -47,6 +47,8 @@ from airflow.utils.helpers import convert_camel_to_snake from airflow.utils.state import State +pytestmark = pytest.mark.db_test + ARN1 = "arn1" ARN2 = "arn2" ARN3 = "arn3" diff --git a/tests/providers/amazon/aws/hooks/test_base_aws.py b/tests/providers/amazon/aws/hooks/test_base_aws.py index 85964433e2fc4..13e21f0ad93cc 100644 --- a/tests/providers/amazon/aws/hooks/test_base_aws.py +++ b/tests/providers/amazon/aws/hooks/test_base_aws.py @@ -878,6 +878,7 @@ def test_hook_connection_test(self): assert result assert hook.client_type == "s3" # Same client_type which defined during initialisation + @pytest.mark.db_test @mock.patch("boto3.session.Session") def test_hook_connection_test_failed(self, mock_boto3_session): """Test ``test_connection`` failure.""" @@ -1144,6 +1145,7 @@ def test_waiter_config_params_not_provided(waiter_path_mock: MagicMock, caplog): assert "PARAM_1" in str(ae.value) +@pytest.mark.db_test @mock.patch.object(AwsGenericHook, "waiter_path", new_callable=PropertyMock) def test_waiter_config_no_params_needed(waiter_path_mock: MagicMock, caplog): waiter_path_mock.return_value = TEST_WAITER_CONFIG_LOCATION diff --git a/tests/providers/amazon/aws/hooks/test_chime.py b/tests/providers/amazon/aws/hooks/test_chime.py index 4de5b97f1ec91..9a54218a0a40d 100644 --- a/tests/providers/amazon/aws/hooks/test_chime.py +++ b/tests/providers/amazon/aws/hooks/test_chime.py @@ -26,6 +26,8 @@ from airflow.providers.amazon.aws.hooks.chime import ChimeWebhookHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestChimeWebhookHook: _config = { diff --git a/tests/providers/amazon/aws/hooks/test_emr.py b/tests/providers/amazon/aws/hooks/test_emr.py index b9864e84dbc18..4de79967f8b0e 100644 --- a/tests/providers/amazon/aws/hooks/test_emr.py +++ b/tests/providers/amazon/aws/hooks/test_emr.py @@ -152,6 +152,7 @@ def test_add_job_flow_steps_raises_exception_on_failure(self, mock_conn, mock_sl assert "test failure details" in caplog.messages[-1] mock_conn.get_waiter.assert_called_with("step_complete") + @pytest.mark.db_test @mock_emr def test_create_job_flow_extra_args(self): """ diff --git a/tests/providers/amazon/aws/hooks/test_s3.py b/tests/providers/amazon/aws/hooks/test_s3.py index c802fc5e5e7da..2ff2207687d30 100644 --- a/tests/providers/amazon/aws/hooks/test_s3.py +++ b/tests/providers/amazon/aws/hooks/test_s3.py @@ -1285,6 +1285,7 @@ def test_delete_bucket_tagging_with_no_tags(self): hook.get_bucket_tagging(bucket_name="new_bucket") +@pytest.mark.db_test @pytest.mark.parametrize( "key_kind, has_conn, has_bucket, precedence, expected", [ diff --git a/tests/providers/amazon/aws/links/test_links.py b/tests/providers/amazon/aws/links/test_links.py index 68b60657fbfbb..e0ccf86d2e2da 100644 --- a/tests/providers/amazon/aws/links/test_links.py +++ b/tests/providers/amazon/aws/links/test_links.py @@ -86,6 +86,7 @@ def _full_qualname(cls) -> str: ] +@pytest.mark.db_test @pytest.mark.need_serialized_dag class TestAwsLinks: @pytest.mark.parametrize("extra_link_class", map(itemgetter(0), AWS_LINKS), ids=_full_qualname) diff --git a/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py b/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py index b3c1cd6e39c45..4a43aec42930a 100644 --- a/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py +++ b/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py @@ -51,6 +51,7 @@ def logmock(): yield +@pytest.mark.db_test class TestCloudwatchTaskHandler: @conf_vars({("logging", "remote_log_conn_id"): "aws_default"}) @pytest.fixture(autouse=True) diff --git a/tests/providers/amazon/aws/log/test_s3_task_handler.py b/tests/providers/amazon/aws/log/test_s3_task_handler.py index 7d06430420351..1e7e32d93117f 100644 --- a/tests/providers/amazon/aws/log/test_s3_task_handler.py +++ b/tests/providers/amazon/aws/log/test_s3_task_handler.py @@ -43,6 +43,7 @@ def s3mock(): yield +@pytest.mark.db_test class TestS3TaskHandler: @conf_vars({("logging", "remote_log_conn_id"): "aws_default"}) @pytest.fixture(autouse=True) diff --git a/tests/providers/amazon/aws/notifications/test_chime.py b/tests/providers/amazon/aws/notifications/test_chime.py index 5dc774d0d5e8a..022a1b35a507a 100644 --- a/tests/providers/amazon/aws/notifications/test_chime.py +++ b/tests/providers/amazon/aws/notifications/test_chime.py @@ -19,12 +19,16 @@ from unittest import mock +import pytest + from airflow.models import Connection from airflow.operators.empty import EmptyOperator from airflow.providers.amazon.aws.hooks.chime import ChimeWebhookHook from airflow.providers.amazon.aws.notifications.chime import ChimeNotifier, send_chime_notification from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestChimeNotifier: # Chime webhooks can't really have a default connection, so we need to create one for tests. diff --git a/tests/providers/amazon/aws/notifications/test_sns.py b/tests/providers/amazon/aws/notifications/test_sns.py index fd70d3bb1d61b..75876228f0518 100644 --- a/tests/providers/amazon/aws/notifications/test_sns.py +++ b/tests/providers/amazon/aws/notifications/test_sns.py @@ -60,6 +60,7 @@ def test_parameters_propagate_to_hook(self, aws_conn_id, region_name): notifier.notify({}) mock_hook.return_value.publish_to_target.assert_called_once_with(**publish_kwargs) + @pytest.mark.db_test def test_sns_notifier_templated(self, dag_maker): with dag_maker("test_sns_notifier_templated") as dag: EmptyOperator(task_id="task1") diff --git a/tests/providers/amazon/aws/notifications/test_sqs.py b/tests/providers/amazon/aws/notifications/test_sqs.py index c3071e559e0e7..4ace17eee3dd7 100644 --- a/tests/providers/amazon/aws/notifications/test_sqs.py +++ b/tests/providers/amazon/aws/notifications/test_sqs.py @@ -61,6 +61,7 @@ def test_parameters_propagate_to_hook(self, aws_conn_id, region_name): notifier.notify({}) mock_hook.return_value.send_message.assert_called_once_with(**send_message_kwargs) + @pytest.mark.db_test def test_sqs_notifier_templated(self, dag_maker): with dag_maker("test_sns_notifier_templated") as dag: EmptyOperator(task_id="task1") diff --git a/tests/providers/amazon/aws/operators/test_appflow.py b/tests/providers/amazon/aws/operators/test_appflow.py index dc3c2fddca86a..3d53e99ea3690 100644 --- a/tests/providers/amazon/aws/operators/test_appflow.py +++ b/tests/providers/amazon/aws/operators/test_appflow.py @@ -52,6 +52,7 @@ AppflowBaseOperator.UPDATE_PROPAGATION_TIME = 0 # avoid wait +@pytest.mark.db_test @pytest.fixture def ctx(create_task_instance): ti = create_task_instance( @@ -111,6 +112,7 @@ def run_assertions_base(appflow_conn, tasks): appflow_conn.start_flow.assert_called_once_with(flowName=FLOW_NAME) +@pytest.mark.db_test def test_run(appflow_conn, ctx, waiter_mock): operator = AppflowRunOperator(**DUMP_COMMON_ARGS) operator.execute(ctx) # type: ignore @@ -118,12 +120,14 @@ def test_run(appflow_conn, ctx, waiter_mock): appflow_conn.describe_flow_execution_records.assert_called_once() +@pytest.mark.db_test def test_run_full(appflow_conn, ctx, waiter_mock): operator = AppflowRunFullOperator(**DUMP_COMMON_ARGS) operator.execute(ctx) # type: ignore run_assertions_base(appflow_conn, []) +@pytest.mark.db_test def test_run_after(appflow_conn, ctx, waiter_mock): operator = AppflowRunAfterOperator( source_field="col0", filter_date="2022-05-26T00:00+00:00", **DUMP_COMMON_ARGS @@ -142,6 +146,7 @@ def test_run_after(appflow_conn, ctx, waiter_mock): ) +@pytest.mark.db_test def test_run_before(appflow_conn, ctx, waiter_mock): operator = AppflowRunBeforeOperator( source_field="col0", filter_date="2022-05-26T00:00+00:00", **DUMP_COMMON_ARGS @@ -160,6 +165,7 @@ def test_run_before(appflow_conn, ctx, waiter_mock): ) +@pytest.mark.db_test def test_run_daily(appflow_conn, ctx, waiter_mock): operator = AppflowRunDailyOperator( source_field="col0", filter_date="2022-05-26T00:00+00:00", **DUMP_COMMON_ARGS @@ -182,6 +188,7 @@ def test_run_daily(appflow_conn, ctx, waiter_mock): ) +@pytest.mark.db_test def test_short_circuit(appflow_conn, ctx): with mock.patch("airflow.models.TaskInstance.xcom_pull") as mock_xcom_pull: with mock.patch("airflow.models.TaskInstance.xcom_push") as mock_xcom_push: diff --git a/tests/providers/amazon/aws/operators/test_athena.py b/tests/providers/amazon/aws/operators/test_athena.py index 698535e26e2f0..ce7a88f45ecc1 100644 --- a/tests/providers/amazon/aws/operators/test_athena.py +++ b/tests/providers/amazon/aws/operators/test_athena.py @@ -190,6 +190,7 @@ def test_hook_run_failed_query_with_max_tries(self, mock_conn, mock_run_query, m MOCK_DATA["workgroup"], ) + @pytest.mark.db_test @mock.patch.object(AthenaHook, "check_query_status", side_effect=("SUCCEEDED",)) @mock.patch.object(AthenaHook, "run_query", return_value=ATHENA_QUERY_ID) @mock.patch.object(AthenaHook, "get_conn") diff --git a/tests/providers/amazon/aws/operators/test_base_aws.py b/tests/providers/amazon/aws/operators/test_base_aws.py index e543cbb22825a..4cc9080029e4f 100644 --- a/tests/providers/amazon/aws/operators/test_base_aws.py +++ b/tests/providers/amazon/aws/operators/test_base_aws.py @@ -91,6 +91,7 @@ def test_parameters(self): assert hook._config.read_timeout == 777 assert hook._config.connect_timeout == 42 + @pytest.mark.db_test @pytest.mark.parametrize( "op_kwargs", [ diff --git a/tests/providers/amazon/aws/operators/test_datasync.py b/tests/providers/amazon/aws/operators/test_datasync.py index 57a032d919bda..829dca7082226 100644 --- a/tests/providers/amazon/aws/operators/test_datasync.py +++ b/tests/providers/amazon/aws/operators/test_datasync.py @@ -304,6 +304,7 @@ def test_execute_specific_task(self, mock_get_conn): # ### Check mocks: mock_get_conn.assert_called() + @pytest.mark.db_test def test_return_value(self, mock_get_conn): """Test we return the right value -- that will get put in to XCom by the execution engine""" # ### Set up mocks: @@ -496,6 +497,7 @@ def test_execute_specific_task(self, mock_get_conn): # ### Check mocks: mock_get_conn.assert_called() + @pytest.mark.db_test def test_return_value(self, mock_get_conn): """Test we return the right value -- that will get put in to XCom by the execution engine""" # ### Set up mocks: @@ -594,6 +596,7 @@ def test_execute_specific_task(self, mock_get_conn): # ### Check mocks: mock_get_conn.assert_called() + @pytest.mark.db_test def test_return_value(self, mock_get_conn): """Test we return the right value -- that will get put in to XCom by the execution engine""" # ### Set up mocks: @@ -764,6 +767,7 @@ def test_execute_specific_task(self, mock_get_conn): # ### Check mocks: mock_get_conn.assert_called() + @pytest.mark.db_test def test_return_value(self, mock_get_conn): """Test we return the right value -- that will get put in to XCom by the execution engine""" # ### Set up mocks: @@ -858,6 +862,7 @@ def test_execute_specific_task(self, mock_get_conn): # ### Check mocks: mock_get_conn.assert_called() + @pytest.mark.db_test def test_return_value(self, mock_get_conn): """Test we return the right value -- that will get put in to XCom by the execution engine""" # ### Set up mocks: diff --git a/tests/providers/amazon/aws/operators/test_dms_describe_tasks.py b/tests/providers/amazon/aws/operators/test_dms_describe_tasks.py index 6599af0207083..2ebc294f8303a 100644 --- a/tests/providers/amazon/aws/operators/test_dms_describe_tasks.py +++ b/tests/providers/amazon/aws/operators/test_dms_describe_tasks.py @@ -19,6 +19,8 @@ import json from unittest import mock +import pytest + from airflow.models import DAG, DagRun, TaskInstance from airflow.providers.amazon.aws.hooks.dms import DmsHook from airflow.providers.amazon.aws.operators.dms import DmsDescribeTasksOperator @@ -78,6 +80,7 @@ def test_describe_tasks(self, mock_conn, mock_describe_replication_tasks): mock_describe_replication_tasks.assert_called_once_with(**describe_tasks_kwargs) + @pytest.mark.db_test @mock.patch.object(DmsHook, "describe_replication_tasks", return_value=(None, MOCK_RESPONSE)) @mock.patch.object(DmsHook, "get_conn") def test_describe_tasks_return_value(self, mock_conn, mock_describe_replication_tasks): diff --git a/tests/providers/amazon/aws/operators/test_emr_add_steps.py b/tests/providers/amazon/aws/operators/test_emr_add_steps.py index 335452b1316e0..9f8d15959dc48 100644 --- a/tests/providers/amazon/aws/operators/test_emr_add_steps.py +++ b/tests/providers/amazon/aws/operators/test_emr_add_steps.py @@ -96,6 +96,7 @@ def test_validate_mutually_exclusive_args(self, job_flow_id, job_flow_name): job_flow_name=job_flow_name, ) + @pytest.mark.db_test def test_render_template(self): dag_run = DagRun(dag_id=self.operator.dag.dag_id, execution_date=DEFAULT_DATE, run_id="test") ti = TaskInstance(task=self.operator) @@ -119,6 +120,7 @@ def test_render_template(self): assert self.operator.steps == expected_args + @pytest.mark.db_test def test_render_template_from_file(self, mocked_hook_client): dag = DAG( dag_id="test_file", diff --git a/tests/providers/amazon/aws/operators/test_emr_create_job_flow.py b/tests/providers/amazon/aws/operators/test_emr_create_job_flow.py index 82cb2e245b27f..2b76fadb442dd 100644 --- a/tests/providers/amazon/aws/operators/test_emr_create_job_flow.py +++ b/tests/providers/amazon/aws/operators/test_emr_create_job_flow.py @@ -92,6 +92,7 @@ def test_init(self): assert self.operator.emr_conn_id == "emr_default" assert self.operator.region_name == "ap-southeast-2" + @pytest.mark.db_test def test_render_template(self): self.operator.job_flow_overrides = self._config dag_run = DagRun(dag_id=self.operator.dag_id, execution_date=DEFAULT_DATE, run_id="test") @@ -120,6 +121,7 @@ def test_render_template(self): assert self.operator.job_flow_overrides == expected_args + @pytest.mark.db_test def test_render_template_from_file(self, mocked_hook_client): self.operator.job_flow_overrides = "job.j2.json" self.operator.params = {"releaseLabel": "5.11.0"} diff --git a/tests/providers/amazon/aws/operators/test_sagemaker_base.py b/tests/providers/amazon/aws/operators/test_sagemaker_base.py index ddac1231b0f4f..d879f5925ebbe 100644 --- a/tests/providers/amazon/aws/operators/test_sagemaker_base.py +++ b/tests/providers/amazon/aws/operators/test_sagemaker_base.py @@ -80,6 +80,7 @@ def test_job_not_unique_with_fail(self): self.sagemaker._get_unique_job_name("test", True, lambda _: None) +@pytest.mark.db_test class TestSageMakerExperimentOperator: @patch("airflow.providers.amazon.aws.hooks.sagemaker.SageMakerHook.conn", new_callable=mock.PropertyMock) def test_create_experiment(self, conn_mock): diff --git a/tests/providers/amazon/aws/sensors/test_base_aws.py b/tests/providers/amazon/aws/sensors/test_base_aws.py index 4c604a084987b..a5cbe23a49824 100644 --- a/tests/providers/amazon/aws/sensors/test_base_aws.py +++ b/tests/providers/amazon/aws/sensors/test_base_aws.py @@ -93,6 +93,7 @@ def test_parameters(self): assert hook._config.read_timeout == 777 assert hook._config.connect_timeout == 42 + @pytest.mark.db_test @pytest.mark.parametrize( "op_kwargs", [ diff --git a/tests/providers/amazon/aws/sensors/test_ecs.py b/tests/providers/amazon/aws/sensors/test_ecs.py index 9480b63b7ab23..46f7dbd4fd3d1 100644 --- a/tests/providers/amazon/aws/sensors/test_ecs.py +++ b/tests/providers/amazon/aws/sensors/test_ecs.py @@ -99,6 +99,7 @@ def test_hook_and_client(self, aws_conn_id, region_name): assert client is self.fake_client +@pytest.mark.db_test class TestEcsClusterStateSensor(EcsBaseTestCase): @pytest.mark.parametrize( "return_state, expected", [("ACTIVE", True), ("PROVISIONING", False), ("DEPROVISIONING", False)] @@ -159,6 +160,7 @@ def test_custom_values_terminal_state(self, failure_states, return_state): m.assert_called_once_with(cluster_name=TEST_CLUSTER_NAME) +@pytest.mark.db_test class TestEcsTaskDefinitionStateSensor(EcsBaseTestCase): @pytest.mark.parametrize( "return_state, expected", [("ACTIVE", True), ("INACTIVE", False), ("DELETE_IN_PROGRESS", False)] @@ -191,6 +193,7 @@ def test_custom_values_poke(self, create_task_of_operator, target_state, return_ m.assert_called_once_with(task_definition=TEST_TASK_DEFINITION_ARN) +@pytest.mark.db_test class TestEcsTaskStateSensor(EcsBaseTestCase): @pytest.mark.parametrize( "return_state, expected", diff --git a/tests/providers/amazon/aws/sensors/test_s3_key.py b/tests/providers/amazon/aws/sensors/test_s3_key.py index ef32be43d2758..cee1137a43eeb 100644 --- a/tests/providers/amazon/aws/sensors/test_s3_key.py +++ b/tests/providers/amazon/aws/sensors/test_s3_key.py @@ -101,6 +101,7 @@ def test_parse_bucket_key(self, mock_head_object, key, bucket, parsed_key, parse mock_head_object.assert_called_once_with(parsed_key, parsed_bucket) + @pytest.mark.db_test @mock.patch("airflow.providers.amazon.aws.sensors.s3.S3Hook.head_object") def test_parse_bucket_key_from_jinja(self, mock_head_object): mock_head_object.return_value = None @@ -126,6 +127,7 @@ def test_parse_bucket_key_from_jinja(self, mock_head_object): mock_head_object.assert_called_once_with("key", "bucket") + @pytest.mark.db_test @mock.patch("airflow.providers.amazon.aws.sensors.s3.S3Hook.head_object") def test_parse_list_of_bucket_keys_from_jinja(self, mock_head_object): mock_head_object.return_value = None diff --git a/tests/providers/amazon/aws/sensors/test_s3_keys_unchanged.py b/tests/providers/amazon/aws/sensors/test_s3_keys_unchanged.py index 56caa9ecc167a..45566d405c871 100644 --- a/tests/providers/amazon/aws/sensors/test_s3_keys_unchanged.py +++ b/tests/providers/amazon/aws/sensors/test_s3_keys_unchanged.py @@ -56,6 +56,7 @@ def test_reschedule_mode_not_allowed(self): dag=self.dag, ) + @pytest.mark.db_test def test_render_template_fields(self): S3KeysUnchangedSensor( task_id="sensor_3", diff --git a/tests/providers/amazon/aws/transfers/test_base.py b/tests/providers/amazon/aws/transfers/test_base.py index b9e1ec29b8d51..64003a45c4952 100644 --- a/tests/providers/amazon/aws/transfers/test_base.py +++ b/tests/providers/amazon/aws/transfers/test_base.py @@ -33,6 +33,7 @@ def setup_method(self): args = {"owner": "airflow", "start_date": DEFAULT_DATE} self.dag = DAG("test_dag_id", default_args=args) + @pytest.mark.db_test def test_render_template(self): operator = AwsToAwsBaseOperator( task_id="dynamodb_to_s3_test_render", diff --git a/tests/providers/amazon/aws/transfers/test_dynamodb_to_s3.py b/tests/providers/amazon/aws/transfers/test_dynamodb_to_s3.py index bc1b9751b74ab..86fa82635fb9e 100644 --- a/tests/providers/amazon/aws/transfers/test_dynamodb_to_s3.py +++ b/tests/providers/amazon/aws/transfers/test_dynamodb_to_s3.py @@ -294,6 +294,7 @@ def test_dynamodb_to_s3_with_just_dest_aws_conn_id(self, mock_aws_dynamodb_hook, mock_aws_dynamodb_hook.assert_called_with(aws_conn_id="aws_default") mock_s3_hook.assert_called_with(aws_conn_id=s3_aws_conn_id) + @pytest.mark.db_test def test_render_template(self): dag = DAG("test_render_template_dag_id", start_date=datetime(2020, 1, 1)) operator = DynamoDBToS3Operator( diff --git a/tests/providers/amazon/aws/transfers/test_google_api_to_s3.py b/tests/providers/amazon/aws/transfers/test_google_api_to_s3.py index 6ddc968d3bd52..d763c32b9cb55 100644 --- a/tests/providers/amazon/aws/transfers/test_google_api_to_s3.py +++ b/tests/providers/amazon/aws/transfers/test_google_api_to_s3.py @@ -27,6 +27,8 @@ from airflow.providers.amazon.aws.transfers.google_api_to_s3 import GoogleApiToS3Operator from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestGoogleApiToS3: def setup_method(self): diff --git a/tests/providers/amazon/aws/transfers/test_mongo_to_s3.py b/tests/providers/amazon/aws/transfers/test_mongo_to_s3.py index ed07fdfab23bb..ba9d158ec788e 100644 --- a/tests/providers/amazon/aws/transfers/test_mongo_to_s3.py +++ b/tests/providers/amazon/aws/transfers/test_mongo_to_s3.py @@ -19,6 +19,8 @@ from unittest import mock +import pytest + from airflow.models import DAG, DagRun, TaskInstance from airflow.providers.amazon.aws.transfers.mongo_to_s3 import MongoToS3Operator from airflow.utils import timezone @@ -75,6 +77,7 @@ def test_template_field_overrides(self): "mongo_collection", ) + @pytest.mark.db_test def test_render_template(self): dag_run = DagRun(dag_id=self.mock_operator.dag_id, execution_date=DEFAULT_DATE, run_id="test") ti = TaskInstance(task=self.mock_operator) diff --git a/tests/providers/amazon/aws/transfers/test_s3_to_sftp.py b/tests/providers/amazon/aws/transfers/test_s3_to_sftp.py index ac55b4835b755..9675e336b1f9d 100644 --- a/tests/providers/amazon/aws/transfers/test_s3_to_sftp.py +++ b/tests/providers/amazon/aws/transfers/test_s3_to_sftp.py @@ -18,6 +18,7 @@ from __future__ import annotations import boto3 +import pytest from moto import mock_s3 from airflow.models import DAG @@ -28,6 +29,9 @@ from airflow.utils.timezone import datetime from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + TASK_ID = "test_s3_to_sftp" BUCKET = "test-s3-bucket" S3_KEY = "test/test_1_file.csv" diff --git a/tests/providers/amazon/aws/transfers/test_s3_to_sql.py b/tests/providers/amazon/aws/transfers/test_s3_to_sql.py index de41e31bc4b86..bc114754eb33d 100644 --- a/tests/providers/amazon/aws/transfers/test_s3_to_sql.py +++ b/tests/providers/amazon/aws/transfers/test_s3_to_sql.py @@ -27,6 +27,8 @@ from airflow.utils import db from airflow.utils.session import create_session +pytestmark = pytest.mark.db_test + class TestS3ToSqlTransfer: def setup_method(self): diff --git a/tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py b/tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py index 7a7d90a5328e6..ab453f9e01b5d 100644 --- a/tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py +++ b/tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py @@ -18,10 +18,15 @@ from unittest import mock +import pytest + from airflow.providers.amazon.aws.hooks.s3 import S3Hook from airflow.providers.amazon.aws.transfers.salesforce_to_s3 import SalesforceToS3Operator from airflow.providers.salesforce.hooks.salesforce import SalesforceHook +pytestmark = pytest.mark.db_test + + TASK_ID = "test-task-id" QUERY = "SELECT id, company FROM Lead WHERE company = 'Hello World Inc'" SALESFORCE_CONNECTION_ID = "test-salesforce-connection" diff --git a/tests/providers/amazon/aws/transfers/test_sftp_to_s3.py b/tests/providers/amazon/aws/transfers/test_sftp_to_s3.py index d3a301c823030..50da4b93cf410 100644 --- a/tests/providers/amazon/aws/transfers/test_sftp_to_s3.py +++ b/tests/providers/amazon/aws/transfers/test_sftp_to_s3.py @@ -29,6 +29,8 @@ from airflow.utils.timezone import datetime from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + BUCKET = "test-bucket" S3_KEY = "test/test_1_file.csv" SFTP_PATH = "/tmp/remote_path.txt" diff --git a/tests/providers/amazon/aws/triggers/test_serialization.py b/tests/providers/amazon/aws/triggers/test_serialization.py index e4a343e98fc08..ed9215d415233 100644 --- a/tests/providers/amazon/aws/triggers/test_serialization.py +++ b/tests/providers/amazon/aws/triggers/test_serialization.py @@ -64,6 +64,8 @@ from airflow.providers.amazon.aws.utils.rds import RdsDbType from airflow.serialization.serialized_objects import BaseSerialization +pytestmark = pytest.mark.db_test + BATCH_JOB_ID = "job_id" TEST_CLUSTER_IDENTIFIER = "test-cluster" diff --git a/tests/providers/amazon/aws/utils/test_connection_wrapper.py b/tests/providers/amazon/aws/utils/test_connection_wrapper.py index 30fffb8fc0f45..7014035cbaef1 100644 --- a/tests/providers/amazon/aws/utils/test_connection_wrapper.py +++ b/tests/providers/amazon/aws/utils/test_connection_wrapper.py @@ -27,6 +27,9 @@ from airflow.models import Connection from airflow.providers.amazon.aws.utils.connection_wrapper import AwsConnectionWrapper, _ConnectionMetadata +pytestmark = pytest.mark.db_test + + MOCK_AWS_CONN_ID = "mock-conn-id" MOCK_CONN_TYPE = "aws" MOCK_ROLE_ARN = "arn:aws:iam::222222222222:role/awesome-role" diff --git a/tests/providers/amazon/aws/utils/test_suppress.py b/tests/providers/amazon/aws/utils/test_suppress.py index 744df42b6e6bb..7323527f65559 100644 --- a/tests/providers/amazon/aws/utils/test_suppress.py +++ b/tests/providers/amazon/aws/utils/test_suppress.py @@ -22,6 +22,7 @@ from airflow.providers.amazon.aws.utils.suppress import return_on_error +@pytest.mark.db_test def test_suppress_function(caplog): @return_on_error("error") def fn(value: str, exc: Exception | None = None) -> str: diff --git a/tests/providers/apache/druid/operators/test_druid.py b/tests/providers/apache/druid/operators/test_druid.py index 86f4650f70e44..f6fba6bffb592 100644 --- a/tests/providers/apache/druid/operators/test_druid.py +++ b/tests/providers/apache/druid/operators/test_druid.py @@ -20,6 +20,8 @@ import json from unittest.mock import MagicMock, patch +import pytest + from airflow.providers.apache.druid.hooks.druid import IngestionType from airflow.providers.apache.druid.operators.druid import DruidOperator from airflow.utils import timezone @@ -48,6 +50,7 @@ } +@pytest.mark.db_test def test_render_template(dag_maker): with dag_maker("test_druid_render_template", default_args={"start_date": DEFAULT_DATE}): operator = DruidOperator( @@ -60,6 +63,7 @@ def test_render_template(dag_maker): assert RENDERED_INDEX == json.loads(operator.json_index_file) +@pytest.mark.db_test def test_render_template_from_file(tmp_path, dag_maker): json_index_file = tmp_path.joinpath("json_index.json") json_index_file.write_text(JSON_INDEX_STR) diff --git a/tests/providers/apache/flink/operators/test_flink_kubernetes.py b/tests/providers/apache/flink/operators/test_flink_kubernetes.py index 3e7cdb01f334e..bbf85d7e8bdb7 100644 --- a/tests/providers/apache/flink/operators/test_flink_kubernetes.py +++ b/tests/providers/apache/flink/operators/test_flink_kubernetes.py @@ -22,11 +22,16 @@ import json from unittest.mock import patch +import pytest + from airflow import DAG from airflow.models import Connection from airflow.providers.apache.flink.operators.flink_kubernetes import FlinkKubernetesOperator from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + TEST_VALID_APPLICATION_YAML = """ apiVersion: flink.apache.org/v1beta1 kind: FlinkDeployment diff --git a/tests/providers/apache/flink/sensors/test_flink_kubernetes.py b/tests/providers/apache/flink/sensors/test_flink_kubernetes.py index f2231ffbe0a9e..6907665712f97 100644 --- a/tests/providers/apache/flink/sensors/test_flink_kubernetes.py +++ b/tests/providers/apache/flink/sensors/test_flink_kubernetes.py @@ -32,6 +32,9 @@ from airflow.providers.apache.flink.sensors.flink_kubernetes import FlinkKubernetesSensor from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + TEST_NO_STATE_CLUSTER = { "apiVersion": "flink.apache.org/v1beta1", "kind": "FlinkDeployment", diff --git a/tests/providers/apache/hive/hooks/test_hive.py b/tests/providers/apache/hive/hooks/test_hive.py index 7a34b0f5c803f..6cb7cadbeded2 100644 --- a/tests/providers/apache/hive/hooks/test_hive.py +++ b/tests/providers/apache/hive/hooks/test_hive.py @@ -62,6 +62,7 @@ def __init__(self): self.iterable = [] +@pytest.mark.db_test class TestHiveCliHook: @mock.patch("tempfile.tempdir", "/tmp/") @mock.patch("tempfile._RandomNameSequence.__next__") @@ -589,6 +590,7 @@ def test_drop_partition(self, get_metastore_client_mock, table_exist_mock): assert metastore_mock.drop_partition(self.table, db=self.database, part_vals=[DEFAULT_DATE_DS]), ret +@pytest.mark.db_test class TestHiveServer2Hook: def _upload_dataframe(self): df = pd.DataFrame({"a": [1, 2], "b": [1, 2]}) @@ -871,6 +873,7 @@ def test_get_results_with_hive_conf(self): assert "test_dag_run_id" in output +@pytest.mark.db_test @mock.patch.dict("os.environ", AIRFLOW__CORE__SECURITY="kerberos") class TestHiveCli: def setup_method(self): diff --git a/tests/providers/apache/hive/sensors/test_named_hive_partition.py b/tests/providers/apache/hive/sensors/test_named_hive_partition.py index ab63156e5e9df..b75c25e6a2973 100644 --- a/tests/providers/apache/hive/sensors/test_named_hive_partition.py +++ b/tests/providers/apache/hive/sensors/test_named_hive_partition.py @@ -33,6 +33,8 @@ DEFAULT_DATE_ISO = DEFAULT_DATE.isoformat() DEFAULT_DATE_DS = DEFAULT_DATE_ISO[:10] +pytestmark = pytest.mark.db_test + class TestNamedHivePartitionSensor: def setup_method(self): diff --git a/tests/providers/apache/hive/transfers/test_vertica_to_hive.py b/tests/providers/apache/hive/transfers/test_vertica_to_hive.py index 142323c41ee81..4fbe5db0d9bdb 100644 --- a/tests/providers/apache/hive/transfers/test_vertica_to_hive.py +++ b/tests/providers/apache/hive/transfers/test_vertica_to_hive.py @@ -20,9 +20,13 @@ import datetime from unittest import mock +import pytest + from airflow.models.dag import DAG from airflow.providers.apache.hive.transfers.vertica_to_hive import VerticaToHiveOperator +pytestmark = pytest.mark.db_test + def mock_get_conn(): commit_mock = mock.MagicMock() diff --git a/tests/providers/apache/kafka/hooks/test_admin_client.py b/tests/providers/apache/kafka/hooks/test_admin_client.py index 651b5a20b6604..16ffa5ac4d354 100644 --- a/tests/providers/apache/kafka/hooks/test_admin_client.py +++ b/tests/providers/apache/kafka/hooks/test_admin_client.py @@ -26,6 +26,8 @@ from airflow.providers.apache.kafka.hooks.client import KafkaAdminClientHook from airflow.utils import db +pytestmark = pytest.mark.db_test + log = logging.getLogger(__name__) diff --git a/tests/providers/apache/kafka/hooks/test_consumer.py b/tests/providers/apache/kafka/hooks/test_consumer.py index 60ac44f1bc132..852d7374489c6 100644 --- a/tests/providers/apache/kafka/hooks/test_consumer.py +++ b/tests/providers/apache/kafka/hooks/test_consumer.py @@ -26,6 +26,8 @@ from airflow.providers.apache.kafka.hooks.consume import KafkaConsumerHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestConsumerHook: """ diff --git a/tests/providers/apache/kafka/hooks/test_producer.py b/tests/providers/apache/kafka/hooks/test_producer.py index 65c827b41cc93..0f5ed0e1865ef 100644 --- a/tests/providers/apache/kafka/hooks/test_producer.py +++ b/tests/providers/apache/kafka/hooks/test_producer.py @@ -25,6 +25,9 @@ from airflow.providers.apache.kafka.hooks.produce import KafkaProducerHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + log = logging.getLogger(__name__) diff --git a/tests/providers/apache/kafka/operators/test_consume.py b/tests/providers/apache/kafka/operators/test_consume.py index a96abf86906a8..699e0abe0643c 100644 --- a/tests/providers/apache/kafka/operators/test_consume.py +++ b/tests/providers/apache/kafka/operators/test_consume.py @@ -21,12 +21,17 @@ from typing import Any from unittest import mock +import pytest + from airflow.models import Connection # Import Operator from airflow.providers.apache.kafka.operators.consume import ConsumeFromTopicOperator from airflow.utils import db +pytestmark = pytest.mark.db_test + + log = logging.getLogger(__name__) diff --git a/tests/providers/apache/kafka/operators/test_produce.py b/tests/providers/apache/kafka/operators/test_produce.py index 46797365e8588..49559984f1d0a 100644 --- a/tests/providers/apache/kafka/operators/test_produce.py +++ b/tests/providers/apache/kafka/operators/test_produce.py @@ -20,10 +20,15 @@ import logging from typing import Any +import pytest + from airflow.models import Connection from airflow.providers.apache.kafka.operators.produce import ProduceToTopicOperator from airflow.utils import db +pytestmark = pytest.mark.db_test + + log = logging.getLogger(__name__) diff --git a/tests/providers/apache/kafka/sensors/test_kafka.py b/tests/providers/apache/kafka/sensors/test_kafka.py index e2c6d8ae7c4ef..d802ac61b8fb3 100644 --- a/tests/providers/apache/kafka/sensors/test_kafka.py +++ b/tests/providers/apache/kafka/sensors/test_kafka.py @@ -27,6 +27,9 @@ from airflow.providers.apache.kafka.sensors.kafka import AwaitMessageSensor, AwaitMessageTriggerFunctionSensor from airflow.utils import db +pytestmark = pytest.mark.db_test + + log = logging.getLogger(__name__) diff --git a/tests/providers/apache/kafka/triggers/test_await_message.py b/tests/providers/apache/kafka/triggers/test_await_message.py index f7f7e675406a7..db17d5e4e758c 100644 --- a/tests/providers/apache/kafka/triggers/test_await_message.py +++ b/tests/providers/apache/kafka/triggers/test_await_message.py @@ -26,6 +26,8 @@ from airflow.providers.apache.kafka.triggers.await_message import AwaitMessageTrigger from airflow.utils import db +pytestmark = pytest.mark.db_test + def apply_function_false(message): return False diff --git a/tests/providers/apache/kylin/hooks/test_kylin.py b/tests/providers/apache/kylin/hooks/test_kylin.py index 812cc8f72cb3e..fc0ff2e720647 100644 --- a/tests/providers/apache/kylin/hooks/test_kylin.py +++ b/tests/providers/apache/kylin/hooks/test_kylin.py @@ -25,6 +25,8 @@ from airflow.exceptions import AirflowException from airflow.providers.apache.kylin.hooks.kylin import KylinHook +pytestmark = pytest.mark.db_test + class TestKylinHook: def setup_method(self) -> None: diff --git a/tests/providers/apache/kylin/operators/test_kylin_cube.py b/tests/providers/apache/kylin/operators/test_kylin_cube.py index 58c1832a0cdd6..c8da00bfe1456 100644 --- a/tests/providers/apache/kylin/operators/test_kylin_cube.py +++ b/tests/providers/apache/kylin/operators/test_kylin_cube.py @@ -147,6 +147,7 @@ def test_execute_build_time_out_error(self, mock_hook): with pytest.raises(AirflowException): operator.execute(None) + @pytest.mark.db_test def test_render_template(self): operator = KylinCubeOperator( task_id="kylin_build_1", diff --git a/tests/providers/apache/livy/hooks/test_livy.py b/tests/providers/apache/livy/hooks/test_livy.py index c8f7e62c4f069..e1e60167a2986 100644 --- a/tests/providers/apache/livy/hooks/test_livy.py +++ b/tests/providers/apache/livy/hooks/test_livy.py @@ -51,6 +51,7 @@ ] +@pytest.mark.db_test class TestLivyHook: @classmethod def setup_class(cls): @@ -83,6 +84,7 @@ def setup_class(cls): def teardown_class(cls): clear_db_connections(add_default_connections_back=True) + @pytest.mark.db_test @pytest.mark.parametrize( "conn_id, expected", [ @@ -649,6 +651,7 @@ def set_conn(self): db.merge_conn(Connection(conn_id="missing_host", conn_type="http", port=1234)) db.merge_conn(Connection(conn_id="invalid_uri", uri="http://invalid_uri:4321")) + @pytest.mark.db_test def test_build_get_hook(self): self.set_conn() connection_url_mapping = { diff --git a/tests/providers/apache/livy/operators/test_livy.py b/tests/providers/apache/livy/operators/test_livy.py index 04e796f09205a..156f4f4d03009 100644 --- a/tests/providers/apache/livy/operators/test_livy.py +++ b/tests/providers/apache/livy/operators/test_livy.py @@ -28,6 +28,9 @@ from airflow.providers.apache.livy.operators.livy import LivyOperator from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2017, 1, 1) BATCH_ID = 100 APP_ID = "application_1433865536131_34483" diff --git a/tests/providers/apache/livy/sensors/test_livy.py b/tests/providers/apache/livy/sensors/test_livy.py index d25f72ccd5c43..099de060a40c9 100644 --- a/tests/providers/apache/livy/sensors/test_livy.py +++ b/tests/providers/apache/livy/sensors/test_livy.py @@ -26,6 +26,9 @@ from airflow.providers.apache.livy.sensors.livy import LivySensor from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2017, 1, 1) diff --git a/tests/providers/apache/livy/triggers/test_livy.py b/tests/providers/apache/livy/triggers/test_livy.py index 0bdf8fad49902..2cf1fbfc99709 100644 --- a/tests/providers/apache/livy/triggers/test_livy.py +++ b/tests/providers/apache/livy/triggers/test_livy.py @@ -97,6 +97,7 @@ async def test_livy_trigger_run_with_poll_interval_error(self, mock_poll_for_ter assert len(task) == 2 assert TriggerEvent({"status": "error"}) in task + @pytest.mark.db_test @pytest.mark.asyncio async def test_livy_trigger_run_with_exception(self): """Test if the task in the trigger failed with a connection error when no connection is mocked.""" @@ -119,6 +120,7 @@ async def test_livy_trigger_run_with_exception(self): in task ) + @pytest.mark.db_test @pytest.mark.asyncio async def test_livy_trigger_poll_for_termination_with_client_error(self): """ diff --git a/tests/providers/apache/pig/hooks/test_pig.py b/tests/providers/apache/pig/hooks/test_pig.py index 03d6eb79afddd..ef80f3c86e48d 100644 --- a/tests/providers/apache/pig/hooks/test_pig.py +++ b/tests/providers/apache/pig/hooks/test_pig.py @@ -85,6 +85,7 @@ def test_run_cli_with_properties(self, popen_mock): for pig_prop in test_properties.split(): assert pig_prop in popen_first_arg + @pytest.mark.db_test def test_runtime_exception_not_raised_by_default(self): PigCliHook() diff --git a/tests/providers/apache/pig/operators/test_pig.py b/tests/providers/apache/pig/operators/test_pig.py index 1b7e5d8c9f91b..ef281fdabe406 100644 --- a/tests/providers/apache/pig/operators/test_pig.py +++ b/tests/providers/apache/pig/operators/test_pig.py @@ -18,6 +18,8 @@ from unittest import mock +import pytest + from airflow.providers.apache.pig.hooks.pig import PigCliHook from airflow.providers.apache.pig.operators.pig import PigOperator @@ -40,6 +42,7 @@ def test_prepare_template(self): operator.prepare_template() assert "sh echo {{ DATE }};" == operator.pig + @pytest.mark.db_test @mock.patch.object(PigCliHook, "run_cli") def test_execute(self, mock_run_cli): pig_opts = "-x mapreduce" @@ -48,6 +51,7 @@ def test_execute(self, mock_run_cli): mock_run_cli.assert_called_once_with(pig=PIG, pig_opts=pig_opts) + @pytest.mark.db_test @mock.patch.object(PigCliHook, "run_cli") def test_execute_default_pig_opts_to_none(self, mock_run_cli): operator = PigOperator(pig=PIG, task_id=TEST_TASK_ID) @@ -55,6 +59,7 @@ def test_execute_default_pig_opts_to_none(self, mock_run_cli): mock_run_cli.assert_called_once_with(pig=PIG, pig_opts=None) + @pytest.mark.db_test @mock.patch.object(PigCliHook, "run_cli") @mock.patch.object(PigCliHook, "kill") def test_on_kill(self, mock_kill, mock_rul_cli): diff --git a/tests/providers/apache/pinot/hooks/test_pinot.py b/tests/providers/apache/pinot/hooks/test_pinot.py index 6c60c5d6ec1e7..fbedf1fb9a81f 100644 --- a/tests/providers/apache/pinot/hooks/test_pinot.py +++ b/tests/providers/apache/pinot/hooks/test_pinot.py @@ -202,6 +202,7 @@ def test_run_cli_failure_status_code(self, mock_popen): ) +@pytest.mark.db_test class TestPinotAdminHookCreation: def test_exception_when_overriding_cmd_path(self): with pytest.raises(RuntimeError): diff --git a/tests/providers/apache/spark/hooks/test_spark_jdbc.py b/tests/providers/apache/spark/hooks/test_spark_jdbc.py index 2ee2c3022d641..e3a34cfe26b51 100644 --- a/tests/providers/apache/spark/hooks/test_spark_jdbc.py +++ b/tests/providers/apache/spark/hooks/test_spark_jdbc.py @@ -25,6 +25,8 @@ from airflow.providers.apache.spark.hooks.spark_jdbc import SparkJDBCHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestSparkJDBCHook: _config = { diff --git a/tests/providers/apache/spark/hooks/test_spark_sql.py b/tests/providers/apache/spark/hooks/test_spark_sql.py index ee0f4f359ca94..64ebeb6be4180 100644 --- a/tests/providers/apache/spark/hooks/test_spark_sql.py +++ b/tests/providers/apache/spark/hooks/test_spark_sql.py @@ -29,6 +29,8 @@ from airflow.utils import db from tests.test_utils.db import clear_db_connections +pytestmark = pytest.mark.db_test + def get_after(sentinel, iterable): """Get the value after `sentinel` in an `iterable`""" diff --git a/tests/providers/apache/spark/hooks/test_spark_submit.py b/tests/providers/apache/spark/hooks/test_spark_submit.py index 9bf828e94da83..fbd2c9999a754 100644 --- a/tests/providers/apache/spark/hooks/test_spark_submit.py +++ b/tests/providers/apache/spark/hooks/test_spark_submit.py @@ -28,6 +28,8 @@ from airflow.providers.apache.spark.hooks.spark_submit import SparkSubmitHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestSparkSubmitHook: _spark_job_file = "test_application.py" diff --git a/tests/providers/apache/spark/operators/test_spark_submit.py b/tests/providers/apache/spark/operators/test_spark_submit.py index 4712978d2514a..cf131fdc1a876 100644 --- a/tests/providers/apache/spark/operators/test_spark_submit.py +++ b/tests/providers/apache/spark/operators/test_spark_submit.py @@ -19,6 +19,8 @@ from datetime import timedelta +import pytest + from airflow.models import DagRun, TaskInstance from airflow.models.dag import DAG from airflow.providers.apache.spark.operators.spark_submit import SparkSubmitOperator @@ -141,6 +143,7 @@ def test_execute(self): assert expected_dict["application_args"] == operator._application_args assert expected_dict["spark_binary"] == operator._spark_binary + @pytest.mark.db_test def test_render_template(self): # Given operator = SparkSubmitOperator(task_id="spark_submit_job", dag=self.dag, **self._config) diff --git a/tests/providers/apache/sqoop/hooks/test_sqoop.py b/tests/providers/apache/sqoop/hooks/test_sqoop.py index f28c139509dbc..fd1a6f5807ce5 100644 --- a/tests/providers/apache/sqoop/hooks/test_sqoop.py +++ b/tests/providers/apache/sqoop/hooks/test_sqoop.py @@ -29,6 +29,8 @@ from airflow.providers.apache.sqoop.hooks.sqoop import SqoopHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestSqoopHook: _config = { diff --git a/tests/providers/apprise/notifications/test_apprise.py b/tests/providers/apprise/notifications/test_apprise.py index c81fcbd332b92..e6e2da12e4b9f 100644 --- a/tests/providers/apprise/notifications/test_apprise.py +++ b/tests/providers/apprise/notifications/test_apprise.py @@ -19,6 +19,7 @@ from unittest import mock +import pytest from apprise import NotifyType from airflow.operators.empty import EmptyOperator @@ -27,6 +28,8 @@ send_apprise_notification, ) +pytestmark = pytest.mark.db_test + class TestAppriseNotifier: @mock.patch("airflow.providers.apprise.notifications.apprise.AppriseHook") diff --git a/tests/providers/arangodb/hooks/test_arangodb.py b/tests/providers/arangodb/hooks/test_arangodb.py index 27676dffbd0d3..4b663d86dc3da 100644 --- a/tests/providers/arangodb/hooks/test_arangodb.py +++ b/tests/providers/arangodb/hooks/test_arangodb.py @@ -18,10 +18,15 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.providers.arangodb.hooks.arangodb import ArangoDBHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + arangodb_client_mock = Mock(name="arangodb_client_for_test") diff --git a/tests/providers/arangodb/sensors/test_arangodb.py b/tests/providers/arangodb/sensors/test_arangodb.py index 5b9273b77439b..c039105a6effa 100644 --- a/tests/providers/arangodb/sensors/test_arangodb.py +++ b/tests/providers/arangodb/sensors/test_arangodb.py @@ -19,11 +19,16 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.models.dag import DAG from airflow.providers.arangodb.sensors.arangodb import AQLSensor from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2017, 1, 1) arangodb_hook_mock = Mock(name="arangodb_hook_for_test", **{"query.return_value.count.return_value": 1}) diff --git a/tests/providers/asana/operators/test_asana_tasks.py b/tests/providers/asana/operators/test_asana_tasks.py index 6b7c373d69fcb..e7851a3e18030 100644 --- a/tests/providers/asana/operators/test_asana_tasks.py +++ b/tests/providers/asana/operators/test_asana_tasks.py @@ -18,6 +18,8 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.models.dag import DAG from airflow.providers.asana.operators.asana_tasks import ( @@ -28,6 +30,9 @@ ) from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2015, 1, 1) TEST_DAG_ID = "unit_test_dag" asana_client_mock = Mock(name="asana_client_for_test") diff --git a/tests/providers/atlassian/jira/hooks/test_jira.py b/tests/providers/atlassian/jira/hooks/test_jira.py index 3039218afc4a7..930767fb68c87 100644 --- a/tests/providers/atlassian/jira/hooks/test_jira.py +++ b/tests/providers/atlassian/jira/hooks/test_jira.py @@ -19,10 +19,15 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.providers.atlassian.jira.hooks.jira import JiraHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + jira_client_mock = Mock(name="jira_client") diff --git a/tests/providers/atlassian/jira/operators/test_jira.py b/tests/providers/atlassian/jira/operators/test_jira.py index 101df03d3f337..f1c64d0b8fb60 100644 --- a/tests/providers/atlassian/jira/operators/test_jira.py +++ b/tests/providers/atlassian/jira/operators/test_jira.py @@ -19,11 +19,16 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.models.dag import DAG from airflow.providers.atlassian.jira.operators.jira import JiraOperator from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2017, 1, 1) jira_client_mock = Mock(name="jira_client_for_test") diff --git a/tests/providers/atlassian/jira/sensors/test_jira.py b/tests/providers/atlassian/jira/sensors/test_jira.py index f845f72f31c79..b233b385f1ccb 100644 --- a/tests/providers/atlassian/jira/sensors/test_jira.py +++ b/tests/providers/atlassian/jira/sensors/test_jira.py @@ -19,11 +19,15 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.models.dag import DAG from airflow.providers.atlassian.jira.sensors.jira import JiraTicketSensor from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2017, 1, 1) jira_client_mock = Mock(name="jira_client_for_test") diff --git a/tests/providers/celery/executors/test_celery_executor.py b/tests/providers/celery/executors/test_celery_executor.py index 236054ead393b..9cdb0d7cbff87 100644 --- a/tests/providers/celery/executors/test_celery_executor.py +++ b/tests/providers/celery/executors/test_celery_executor.py @@ -44,6 +44,9 @@ from tests.test_utils import db from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + FAKE_EXCEPTION_MSG = "Fake Exception" diff --git a/tests/providers/cloudant/hooks/test_cloudant.py b/tests/providers/cloudant/hooks/test_cloudant.py index 22911cf1e0d30..8e7d3cd9a760a 100644 --- a/tests/providers/cloudant/hooks/test_cloudant.py +++ b/tests/providers/cloudant/hooks/test_cloudant.py @@ -25,6 +25,8 @@ from airflow.models import Connection from airflow.providers.cloudant.hooks.cloudant import CloudantHook +pytestmark = pytest.mark.db_test + class TestCloudantHook: def setup_method(self): diff --git a/tests/providers/cncf/kubernetes/decorators/test_kubernetes.py b/tests/providers/cncf/kubernetes/decorators/test_kubernetes.py index b3ac936fdae6d..5ceaf2ad259a6 100644 --- a/tests/providers/cncf/kubernetes/decorators/test_kubernetes.py +++ b/tests/providers/cncf/kubernetes/decorators/test_kubernetes.py @@ -25,6 +25,9 @@ from airflow.decorators import setup, task, teardown from airflow.utils import timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2021, 9, 1) KPO_MODULE = "airflow.providers.cncf.kubernetes.operators.pod" diff --git a/tests/providers/cncf/kubernetes/executors/test_kubernetes_executor.py b/tests/providers/cncf/kubernetes/executors/test_kubernetes_executor.py index 4e7e7a65c9fdf..9fe5b27fe90db 100644 --- a/tests/providers/cncf/kubernetes/executors/test_kubernetes_executor.py +++ b/tests/providers/cncf/kubernetes/executors/test_kubernetes_executor.py @@ -159,6 +159,7 @@ def test_execution_date_serialize_deserialize(self): assert datetime_obj == new_datetime_obj + @pytest.mark.db_test @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" ) @@ -181,6 +182,7 @@ def test_delete_pod_successfully(self, mock_watcher, mock_client, mock_kube_clie finally: kube_executor.end() + @pytest.mark.db_test @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" ) @@ -204,6 +206,7 @@ def test_delete_pod_raises_404(self, mock_watcher, mock_client, mock_kube_client kube_executor.kube_scheduler.delete_pod(pod_name, namespace) mock_delete_namespace.assert_called_with(pod_name, namespace, body=mock_client.V1DeleteOptions()) + @pytest.mark.db_test @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" ) @@ -252,6 +255,7 @@ def setup_method(self) -> None: self.kubernetes_executor = KubernetesExecutor() self.kubernetes_executor.job_id = 5 + @pytest.mark.db_test @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" ) @@ -330,6 +334,7 @@ def test_run_next_exception_requeue( finally: kubernetes_executor.end() + @pytest.mark.db_test @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" ) @@ -369,6 +374,7 @@ def test_run_next_pmh_error(self, mock_get_kube_client, mock_pmh): finally: kubernetes_executor.end() + @pytest.mark.db_test @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" ) @@ -432,6 +438,7 @@ def test_gauge_executor_metrics(self, mock_stats_gauge, mock_trigger_tasks, mock ] mock_stats_gauge.assert_has_calls(calls) + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.KubernetesJobWatcher") @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") def test_invalid_executor_config(self, mock_get_kube_client, mock_kubernetes_job_watcher): @@ -454,6 +461,7 @@ def test_invalid_executor_config(self, mock_get_kube_client, mock_kubernetes_job finally: executor.end() + @pytest.mark.db_test @pytest.mark.execution_timeout(10) @pytest.mark.skipif( AirflowKubernetesScheduler is None, reason="kubernetes python package is not installed" @@ -545,6 +553,7 @@ def test_pod_template_file_override_in_executor_config(self, mock_get_kube_clien finally: executor.end() + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.KubernetesJobWatcher") @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") def test_change_state_running(self, mock_get_kube_client, mock_kubernetes_job_watcher): @@ -559,6 +568,7 @@ def test_change_state_running(self, mock_get_kube_client, mock_kubernetes_job_wa finally: executor.end() + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.KubernetesJobWatcher") @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") @mock.patch( @@ -577,6 +587,7 @@ def test_change_state_success(self, mock_delete_pod, mock_get_kube_client, mock_ finally: executor.end() + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.KubernetesJobWatcher") @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") @mock.patch( @@ -602,6 +613,7 @@ def test_change_state_failed_no_deletion( finally: executor.end() + @pytest.mark.db_test @pytest.mark.parametrize( "ti_state", [TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, TaskInstanceState.DEFERRED] ) @@ -632,6 +644,7 @@ def test_change_state_none( finally: executor.end() + @pytest.mark.db_test @pytest.mark.parametrize( "multi_namespace_mode_namespace_list, watchers_keys", [ @@ -655,6 +668,7 @@ def test_watchers_under_multi_namespace_mode( finally: executor.end() + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.KubernetesJobWatcher") @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") @mock.patch( @@ -681,6 +695,7 @@ def test_change_state_skip_pod_deletion( finally: executor.end() + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.KubernetesJobWatcher") @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") @mock.patch( @@ -941,6 +956,7 @@ def test_not_adopt_unassigned_task(self, mock_kube_client): assert not mock_kube_client.patch_namespaced_pod.called assert tis_to_flush_by_key == {"foobar": {}} + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") @mock.patch( "airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.AirflowKubernetesScheduler.delete_pod" @@ -985,6 +1001,7 @@ def test_kube_config_get_namespace_list( assert executor.kube_config.multi_namespace_mode_namespace_list == expected_value_in_kube_config + @pytest.mark.db_test def test_clear_not_launched_queued_tasks_not_launched(self, dag_maker, create_dummy_dag, session): """If a pod isn't found for a TI, reset the state to scheduled""" mock_kube_client = mock.MagicMock() @@ -1018,6 +1035,7 @@ def test_clear_not_launched_queued_tasks_not_launched(self, dag_maker, create_du ), ) + @pytest.mark.db_test @pytest.mark.parametrize( "task_queue, kubernetes_queue", [ @@ -1054,6 +1072,7 @@ def test_clear_not_launched_queued_tasks_launched( namespace="default", label_selector="dag_id=test_clear,task_id=task1,airflow-worker=1,run_id=test" ) + @pytest.mark.db_test def test_clear_not_launched_queued_tasks_mapped_task(self, dag_maker, session): """One mapped task has a launched pod - other does not.""" @@ -1111,6 +1130,7 @@ def list_namespaced_pod(*args, **kwargs): any_order=True, ) + @pytest.mark.db_test def test_clear_not_launched_queued_tasks_not_launched_other_queue( self, dag_maker, create_dummy_dag, session ): @@ -1137,6 +1157,7 @@ def test_clear_not_launched_queued_tasks_not_launched_other_queue( assert ti.state == State.QUEUED assert mock_kube_client.list_namespaced_pod.call_count == 0 + @pytest.mark.db_test def test_clear_not_launched_queued_tasks_clear_only_by_job_id(self, dag_maker, create_dummy_dag, session): """clear only not launched queued tasks which are queued by the same executor job""" mock_kube_client = mock.MagicMock() @@ -1168,6 +1189,7 @@ def test_clear_not_launched_queued_tasks_clear_only_by_job_id(self, dag_maker, c assert ti0.state == State.SCHEDULED assert ti1.state == State.QUEUED + @pytest.mark.db_test @mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client") def test_get_task_log(self, mock_get_kube_client, create_task_instance_of_operator): """fetch task log from pod""" diff --git a/tests/providers/cncf/kubernetes/hooks/test_kubernetes.py b/tests/providers/cncf/kubernetes/hooks/test_kubernetes.py index fb7de29655a0b..cfbd6631b8da2 100644 --- a/tests/providers/cncf/kubernetes/hooks/test_kubernetes.py +++ b/tests/providers/cncf/kubernetes/hooks/test_kubernetes.py @@ -38,6 +38,9 @@ from tests.test_utils.db import clear_db_connections from tests.test_utils.providers import get_provider_min_airflow_version +pytestmark = pytest.mark.db_test + + KUBE_CONFIG_PATH = os.getenv("KUBECONFIG", "~/.kube/config") HOOK_MODULE = "airflow.providers.cncf.kubernetes.hooks.kubernetes" diff --git a/tests/providers/cncf/kubernetes/operators/test_pod.py b/tests/providers/cncf/kubernetes/operators/test_pod.py index ee38c013b3b6f..4ad631ac4e604 100644 --- a/tests/providers/cncf/kubernetes/operators/test_pod.py +++ b/tests/providers/cncf/kubernetes/operators/test_pod.py @@ -40,6 +40,9 @@ from airflow.utils.types import DagRunType from tests.test_utils import db +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2016, 1, 1, 1, 0, 0) KPO_MODULE = "airflow.providers.cncf.kubernetes.operators.pod" POD_MANAGER_CLASS = "airflow.providers.cncf.kubernetes.utils.pod_manager.PodManager" diff --git a/tests/providers/cncf/kubernetes/sensors/test_spark_kubernetes.py b/tests/providers/cncf/kubernetes/sensors/test_spark_kubernetes.py index 8189f48e93412..a832fed97b28c 100644 --- a/tests/providers/cncf/kubernetes/sensors/test_spark_kubernetes.py +++ b/tests/providers/cncf/kubernetes/sensors/test_spark_kubernetes.py @@ -29,6 +29,9 @@ from airflow.providers.cncf.kubernetes.sensors.spark_kubernetes import SparkKubernetesSensor from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + TEST_COMPLETED_APPLICATION = { "apiVersion": "sparkoperator.k8s.io/v1beta2", "kind": "SparkApplication", diff --git a/tests/providers/cncf/kubernetes/test_template_rendering.py b/tests/providers/cncf/kubernetes/test_template_rendering.py index 82a5d80102c0b..0627eb8d586f2 100644 --- a/tests/providers/cncf/kubernetes/test_template_rendering.py +++ b/tests/providers/cncf/kubernetes/test_template_rendering.py @@ -19,6 +19,7 @@ import os from unittest import mock +import pytest from sqlalchemy.orm import make_transient from airflow.configuration import TEST_DAGS_FOLDER @@ -28,6 +29,8 @@ from airflow.version import version from tests.models import DEFAULT_DATE +pytestmark = pytest.mark.db_test + @mock.patch.dict(os.environ, {"AIRFLOW_IS_K8S_EXECUTOR_POD": "True"}) @mock.patch("airflow.settings.pod_mutation_hook") diff --git a/tests/providers/common/sql/hooks/test_sql.py b/tests/providers/common/sql/hooks/test_sql.py index d866ddce0ec4c..eea912340241a 100644 --- a/tests/providers/common/sql/hooks/test_sql.py +++ b/tests/providers/common/sql/hooks/test_sql.py @@ -55,6 +55,7 @@ def get_cursor_descriptions(fields: list[str]) -> list[tuple[str]]: index = 0 +@pytest.mark.db_test @pytest.mark.parametrize( "return_last, split_statements, sql, cursor_calls," "cursor_descriptions, cursor_results, hook_descriptions, hook_results, ", @@ -210,6 +211,7 @@ def mock_execute(*args, **kwargs): dbapi_hook.get_conn.return_value.cursor.return_value.close.assert_called() +@pytest.mark.db_test @pytest.mark.parametrize( "empty_statement", [ diff --git a/tests/providers/common/sql/operators/test_sql.py b/tests/providers/common/sql/operators/test_sql.py index b56efc94d1b80..2344e1c2a3a03 100644 --- a/tests/providers/common/sql/operators/test_sql.py +++ b/tests/providers/common/sql/operators/test_sql.py @@ -43,6 +43,8 @@ from airflow.utils.session import create_session from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class MockHook: def get_records(self): @@ -253,6 +255,7 @@ def test_generate_sql_query_with_partitions(self, monkeypatch): == self.correct_generate_sql_query_with_partition.lstrip() ) + @pytest.mark.db_test def test_generate_sql_query_with_templated_partitions(self, monkeypatch): checks = self.short_valid_column_mapping["X"] operator = self._construct_operator(monkeypatch, self.short_valid_column_mapping, ()) @@ -284,6 +287,7 @@ def test_generate_sql_query_with_check_partition(self, monkeypatch): ) del self.short_valid_column_mapping["X"]["distinct_check"]["partition_clause"] + @pytest.mark.db_test @mock.patch.object(SQLColumnCheckOperator, "get_db_hook") def test_generated_sql_respects_templated_partitions(self, mock_get_db_hook): records = [ @@ -309,6 +313,7 @@ def test_generated_sql_respects_templated_partitions(self, mock_get_db_hook): self._full_check_sql(self.correct_generate_sql_query_with_partition), ) + @pytest.mark.db_test @mock.patch.object(SQLColumnCheckOperator, "get_db_hook") def test_generated_sql_respects_templated_table(self, mock_get_db_hook): records = [ @@ -495,6 +500,7 @@ def test_generate_sql_query_with_partitions(self, monkeypatch): operator._generate_sql_query().lstrip() == self.correct_generate_sql_query_with_partition.lstrip() ) + @pytest.mark.db_test def test_generate_sql_query_with_templated_partitions(self, monkeypatch): operator = self._construct_operator(monkeypatch, self.checks, ()) operator.partition_clause = "{{ params.col }} > 10" @@ -503,6 +509,7 @@ def test_generate_sql_query_with_templated_partitions(self, monkeypatch): operator._generate_sql_query().lstrip() == self.correct_generate_sql_query_with_partition.lstrip() ) + @pytest.mark.db_test def test_generate_sql_query_with_templated_table(self, monkeypatch): operator = self._construct_operator(monkeypatch, self.checks, ()) operator.table = "{{ params.table }}" @@ -645,6 +652,7 @@ def _construct_operator(self, sql, pass_value, tolerance=None): tolerance=tolerance, ) + @pytest.mark.db_test def test_pass_value_template_string(self): pass_value_str = "2018-03-22" operator = self._construct_operator("select date from tab1;", "{{ ds }}") @@ -654,6 +662,7 @@ def test_pass_value_template_string(self): assert operator.task_id == self.task_id assert operator.pass_value == pass_value_str + @pytest.mark.db_test def test_pass_value_template_string_float(self): pass_value_float = 4.0 operator = self._construct_operator("select date from tab1;", pass_value_float) @@ -891,6 +900,7 @@ def test_fail_min_sql_max_value(self, mock_get_db_hook): operator.execute(context=MagicMock()) +@pytest.mark.db_test class TestSqlBranch: """ Test for SQL Branch Operator @@ -919,6 +929,7 @@ def teardown_method(self): session.query(TI).delete() session.query(XCom).delete() + @pytest.mark.db_test def test_unsupported_conn_type(self): """Check if BranchSQLOperator throws an exception for unsupported connection type""" op = BranchSQLOperator( diff --git a/tests/providers/common/sql/sensors/test_sql.py b/tests/providers/common/sql/sensors/test_sql.py index 7491d03e1a2ca..bf4e52c7801b3 100644 --- a/tests/providers/common/sql/sensors/test_sql.py +++ b/tests/providers/common/sql/sensors/test_sql.py @@ -36,6 +36,7 @@ def setup_method(self): args = {"owner": "airflow", "start_date": DEFAULT_DATE} self.dag = DAG(TEST_DAG_ID, default_args=args) + @pytest.mark.db_test def test_unsupported_conn_type(self): op = SqlSensor( task_id="sql_sensor_check", @@ -283,6 +284,7 @@ def test_sql_sensor_postgres_poke_invalid_success( op.poke(None) assert "self.success is present, but not callable -> [1]" == str(ctx.value) + @pytest.mark.db_test def test_sql_sensor_hook_params(self): op = SqlSensor( task_id="sql_sensor_hook_params", diff --git a/tests/providers/daskexecutor/test_dask_executor.py b/tests/providers/daskexecutor/test_dask_executor.py index 248d663265025..8e870cc4b84fe 100644 --- a/tests/providers/daskexecutor/test_dask_executor.py +++ b/tests/providers/daskexecutor/test_dask_executor.py @@ -31,6 +31,8 @@ from airflow.utils import timezone from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + try: # utility functions imported from the dask testing suite to instantiate a test # cluster for tls tests diff --git a/tests/providers/databricks/hooks/test_databricks.py b/tests/providers/databricks/hooks/test_databricks.py index c836691b1e178..e2f74d773e44d 100644 --- a/tests/providers/databricks/hooks/test_databricks.py +++ b/tests/providers/databricks/hooks/test_databricks.py @@ -268,6 +268,7 @@ def setup_mock_requests(mock_requests, exception, status_code=500, error_count=N ] +@pytest.mark.db_test class TestDatabricksHook: """ Tests for DatabricksHook. @@ -949,6 +950,7 @@ def test_connection_failure(self, mock_requests): ) +@pytest.mark.db_test class TestDatabricksHookToken: """ Tests for DatabricksHook when auth is done with token. @@ -978,6 +980,7 @@ def test_submit_run(self, mock_requests): assert kwargs["auth"].token == TOKEN +@pytest.mark.db_test class TestDatabricksHookTokenInPassword: """ Tests for DatabricksHook. @@ -1009,6 +1012,7 @@ def test_submit_run(self, mock_requests): assert kwargs["auth"].token == TOKEN +@pytest.mark.db_test class TestDatabricksHookTokenWhenNoHostIsProvidedInExtra(TestDatabricksHookToken): @provide_session def setup_method(self, method, session=None): @@ -1102,6 +1106,7 @@ def create_aad_token_for_resource(resource: str) -> dict: } +@pytest.mark.db_test class TestDatabricksHookAadToken: """ Tests for DatabricksHook when auth is done with AAD token for SP as user inside workspace. @@ -1139,6 +1144,7 @@ def test_submit_run(self, mock_requests): assert kwargs["auth"].token == TOKEN +@pytest.mark.db_test class TestDatabricksHookAadTokenOtherClouds: """ Tests for DatabricksHook when auth is done with AAD token for SP as user inside workspace and @@ -1186,6 +1192,7 @@ def test_submit_run(self, mock_requests): assert kwargs["auth"].token == TOKEN +@pytest.mark.db_test class TestDatabricksHookAadTokenSpOutside: """ Tests for DatabricksHook when auth is done with AAD token for SP outside of workspace. @@ -1239,6 +1246,7 @@ def test_submit_run(self, mock_requests): assert kwargs["headers"]["X-Databricks-Azure-SP-Management-Token"] == TOKEN +@pytest.mark.db_test class TestDatabricksHookAadTokenManagedIdentity: """ Tests for DatabricksHook when auth is done with AAD leveraging Managed Identity authentication @@ -1282,6 +1290,7 @@ def test_submit_run(self, mock_requests): assert kwargs["auth"].token == TOKEN +@pytest.mark.db_test class TestDatabricksHookAsyncMethods: """ Tests for async functionality of DatabricksHook. @@ -1419,6 +1428,7 @@ async def test_get_cluster_state(self, mock_get): ) +@pytest.mark.db_test class TestDatabricksHookAsyncAadToken: """ Tests for DatabricksHook using async methods when @@ -1461,6 +1471,7 @@ async def test_get_run_state(self, mock_post, mock_get): ) +@pytest.mark.db_test class TestDatabricksHookAsyncAadTokenOtherClouds: """ Tests for DatabricksHook using async methodswhen auth is done with AAD token @@ -1513,6 +1524,7 @@ async def test_get_run_state(self, mock_post, mock_get): ) +@pytest.mark.db_test class TestDatabricksHookAsyncAadTokenSpOutside: """ Tests for DatabricksHook using async methods when auth is done with AAD token for SP outside of workspace. @@ -1579,6 +1591,7 @@ async def test_get_run_state(self, mock_post, mock_get): ) +@pytest.mark.db_test class TestDatabricksHookAsyncAadTokenManagedIdentity: """ Tests for DatabricksHook using async methods when @@ -1628,6 +1641,7 @@ def create_sp_token_for_resource() -> dict: } +@pytest.mark.db_test class TestDatabricksHookSpToken: """ Tests for DatabricksHook when auth is done with Service Principal Oauth token. @@ -1664,6 +1678,7 @@ def test_submit_run(self, mock_requests): assert kwargs["auth"].token == TOKEN +@pytest.mark.db_test class TestDatabricksHookAsyncSpToken: """ Tests for DatabricksHook using async methods when auth is done with Service diff --git a/tests/providers/databricks/hooks/test_databricks_sql.py b/tests/providers/databricks/hooks/test_databricks_sql.py index ae2c07773cf5b..088f5e54a9379 100644 --- a/tests/providers/databricks/hooks/test_databricks_sql.py +++ b/tests/providers/databricks/hooks/test_databricks_sql.py @@ -28,6 +28,8 @@ from airflow.providers.databricks.hooks.databricks_sql import DatabricksSqlHook from airflow.utils.session import provide_session +pytestmark = pytest.mark.db_test + TASK_ID = "databricks-sql-operator" DEFAULT_CONN_ID = "databricks_default" HOST = "xx.cloud.databricks.com" diff --git a/tests/providers/databricks/operators/test_databricks.py b/tests/providers/databricks/operators/test_databricks.py index 5fb1a31cd32bc..73cde92f8bf87 100644 --- a/tests/providers/databricks/operators/test_databricks.py +++ b/tests/providers/databricks/operators/test_databricks.py @@ -36,6 +36,8 @@ from airflow.providers.databricks.triggers.databricks import DatabricksExecutionTrigger from airflow.providers.databricks.utils import databricks as utils +pytestmark = pytest.mark.db_test + DATE = "2017-04-20" TASK_ID = "databricks-operator" DEFAULT_CONN_ID = "databricks_default" @@ -677,6 +679,7 @@ def test_init_with_merging(self): ) assert expected == utils.normalise_json_content(op.json) + @pytest.mark.db_test def test_init_with_templating(self): json = { "new_cluster": NEW_CLUSTER, @@ -1018,6 +1021,7 @@ def test_init_with_merging(self): assert expected == op.json + @pytest.mark.db_test def test_init_with_templating(self): json = {"notebook_params": NOTEBOOK_PARAMS, "jar_params": TEMPLATED_JAR_PARAMS} diff --git a/tests/providers/databricks/sensors/test_databricks_partition.py b/tests/providers/databricks/sensors/test_databricks_partition.py index 839d36d4e9e67..779b3c40937f9 100644 --- a/tests/providers/databricks/sensors/test_databricks_partition.py +++ b/tests/providers/databricks/sensors/test_databricks_partition.py @@ -91,6 +91,7 @@ def test_poke(self, mock_poke, sensor_poke_result, expected_poke_result): mock_poke.return_value = sensor_poke_result assert self.partition_sensor.poke({}) == expected_poke_result + @pytest.mark.db_test def test_unsupported_conn_type(self): with pytest.raises(AirflowException): self.partition_sensor.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) diff --git a/tests/providers/databricks/sensors/test_databricks_sql.py b/tests/providers/databricks/sensors/test_databricks_sql.py index 82dd05d2f51d9..ce05b5456bbfe 100644 --- a/tests/providers/databricks/sensors/test_databricks_sql.py +++ b/tests/providers/databricks/sensors/test_databricks_sql.py @@ -77,6 +77,7 @@ def test_poke(self, mock_poke, sensor_poke_result, expected_poke_result): mock_poke.return_value = sensor_poke_result assert self.sensor.poke({}) == expected_poke_result + @pytest.mark.db_test def test_unsupported_conn_type(self): with pytest.raises(AirflowException): self.sensor.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) diff --git a/tests/providers/databricks/triggers/test_databricks.py b/tests/providers/databricks/triggers/test_databricks.py index 91dcbc418b58e..fc3369cd6e2d8 100644 --- a/tests/providers/databricks/triggers/test_databricks.py +++ b/tests/providers/databricks/triggers/test_databricks.py @@ -27,6 +27,9 @@ from airflow.triggers.base import TriggerEvent from airflow.utils.session import provide_session +pytestmark = pytest.mark.db_test + + DEFAULT_CONN_ID = "databricks_default" HOST = "xx.cloud.databricks.com" LOGIN = "login" diff --git a/tests/providers/datadog/sensors/test_datadog.py b/tests/providers/datadog/sensors/test_datadog.py index a436899acbd7f..c608c9790ef91 100644 --- a/tests/providers/datadog/sensors/test_datadog.py +++ b/tests/providers/datadog/sensors/test_datadog.py @@ -27,6 +27,8 @@ from airflow.providers.datadog.sensors.datadog import DatadogSensor from airflow.utils import db +pytestmark = pytest.mark.db_test + at_least_one_event = [ { "alert_type": "info", diff --git a/tests/providers/dbt/cloud/hooks/test_dbt_cloud.py b/tests/providers/dbt/cloud/hooks/test_dbt_cloud.py index 60800f2454fa4..20e13139654ca 100644 --- a/tests/providers/dbt/cloud/hooks/test_dbt_cloud.py +++ b/tests/providers/dbt/cloud/hooks/test_dbt_cloud.py @@ -33,6 +33,8 @@ ) from airflow.utils import db +pytestmark = pytest.mark.db_test + ACCOUNT_ID_CONN = "account_id_conn" NO_ACCOUNT_ID_CONN = "no_account_id_conn" SINGLE_TENANT_CONN = "single_tenant_conn" diff --git a/tests/providers/dbt/cloud/operators/test_dbt_cloud.py b/tests/providers/dbt/cloud/operators/test_dbt_cloud.py index 471bd1f81c007..b4c1aa89e7087 100644 --- a/tests/providers/dbt/cloud/operators/test_dbt_cloud.py +++ b/tests/providers/dbt/cloud/operators/test_dbt_cloud.py @@ -32,6 +32,8 @@ from airflow.providers.dbt.cloud.triggers.dbt import DbtCloudRunJobTrigger from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + DEFAULT_DATE = timezone.datetime(2021, 1, 1) TASK_ID = "run_job_op" ACCOUNT_ID_CONN = "account_id_conn" diff --git a/tests/providers/dbt/cloud/sensors/test_dbt_cloud.py b/tests/providers/dbt/cloud/sensors/test_dbt_cloud.py index 0ad9b1c349e51..6da4bfc24cc74 100644 --- a/tests/providers/dbt/cloud/sensors/test_dbt_cloud.py +++ b/tests/providers/dbt/cloud/sensors/test_dbt_cloud.py @@ -33,6 +33,9 @@ from airflow.providers.dbt.cloud.triggers.dbt import DbtCloudRunJobTrigger from airflow.utils import db +pytestmark = pytest.mark.db_test + + ACCOUNT_ID = 11111 RUN_ID = 5555 TOKEN = "token" diff --git a/tests/providers/dingding/hooks/test_dingding.py b/tests/providers/dingding/hooks/test_dingding.py index 745fc65bf5397..e2da44736be84 100644 --- a/tests/providers/dingding/hooks/test_dingding.py +++ b/tests/providers/dingding/hooks/test_dingding.py @@ -25,6 +25,8 @@ from airflow.providers.dingding.hooks.dingding import DingdingHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestDingdingHook: conn_id = "dingding_conn_id_test" diff --git a/tests/providers/discord/hooks/test_discord_webhook.py b/tests/providers/discord/hooks/test_discord_webhook.py index 3161619981ef4..3bd019ceffba0 100644 --- a/tests/providers/discord/hooks/test_discord_webhook.py +++ b/tests/providers/discord/hooks/test_discord_webhook.py @@ -26,6 +26,8 @@ from airflow.providers.discord.hooks.discord_webhook import DiscordWebhookHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestDiscordWebhookHook: _config = { diff --git a/tests/providers/discord/notifications/test_discord.py b/tests/providers/discord/notifications/test_discord.py index 279dafa515523..dcf426b6c17da 100644 --- a/tests/providers/discord/notifications/test_discord.py +++ b/tests/providers/discord/notifications/test_discord.py @@ -25,6 +25,8 @@ from airflow.providers.discord.notifications.discord import DiscordNotifier from airflow.utils import db +pytestmark = pytest.mark.db_test + @pytest.fixture(autouse=True) def setup(): diff --git a/tests/providers/docker/decorators/test_docker.py b/tests/providers/docker/decorators/test_docker.py index 8f1691d16f4d7..26d4cb5b6c2d9 100644 --- a/tests/providers/docker/decorators/test_docker.py +++ b/tests/providers/docker/decorators/test_docker.py @@ -25,6 +25,9 @@ from airflow.utils import timezone from airflow.utils.state import TaskInstanceState +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2021, 9, 1) diff --git a/tests/providers/elasticsearch/log/test_es_task_handler.py b/tests/providers/elasticsearch/log/test_es_task_handler.py index def1c0ab457d7..ec2bd3016a217 100644 --- a/tests/providers/elasticsearch/log/test_es_task_handler.py +++ b/tests/providers/elasticsearch/log/test_es_task_handler.py @@ -48,6 +48,9 @@ from .elasticmock import elasticmock from .elasticmock.utilities import SearchFailedException +pytestmark = pytest.mark.db_test + + AIRFLOW_SOURCES_ROOT_DIR = Path(__file__).parents[4].resolve() ES_PROVIDER_YAML_FILE = AIRFLOW_SOURCES_ROOT_DIR / "airflow" / "providers" / "elasticsearch" / "provider.yaml" diff --git a/tests/providers/exasol/hooks/test_sql.py b/tests/providers/exasol/hooks/test_sql.py index 6716e91708a40..4864c83790297 100644 --- a/tests/providers/exasol/hooks/test_sql.py +++ b/tests/providers/exasol/hooks/test_sql.py @@ -29,6 +29,9 @@ from airflow.providers.exasol.hooks.exasol import ExasolHook from airflow.utils.session import provide_session +pytestmark = pytest.mark.db_test + + TASK_ID = "sql-operator" HOST = "host" DEFAULT_CONN_ID = "exasol_default" diff --git a/tests/providers/ftp/hooks/test_ftp.py b/tests/providers/ftp/hooks/test_ftp.py index fd810aa604897..bdd5c0d90c29c 100644 --- a/tests/providers/ftp/hooks/test_ftp.py +++ b/tests/providers/ftp/hooks/test_ftp.py @@ -20,6 +20,8 @@ from io import StringIO from unittest import mock +import pytest + from airflow.providers.ftp.hooks import ftp as fh @@ -134,6 +136,7 @@ def test_connection_failure(self): assert msg == "Test" +@pytest.mark.db_test class TestIntegrationFTPHook: def setup_method(self): from airflow.models import Connection diff --git a/tests/providers/github/hooks/test_github.py b/tests/providers/github/hooks/test_github.py index f10685c4df132..61720e07c9474 100644 --- a/tests/providers/github/hooks/test_github.py +++ b/tests/providers/github/hooks/test_github.py @@ -19,12 +19,16 @@ from unittest.mock import Mock, patch +import pytest from github import BadCredentialsException, Github, NamedUser from airflow.models import Connection from airflow.providers.github.hooks.github import GithubHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + github_client_mock = Mock(name="github_client_for_test") diff --git a/tests/providers/github/operators/test_github.py b/tests/providers/github/operators/test_github.py index 049907375fa7a..23f4c1f9d6d59 100644 --- a/tests/providers/github/operators/test_github.py +++ b/tests/providers/github/operators/test_github.py @@ -19,11 +19,16 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.models.dag import DAG from airflow.providers.github.operators.github import GithubOperator from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2017, 1, 1) github_client_mock = Mock(name="github_client_for_test") diff --git a/tests/providers/github/sensors/test_github.py b/tests/providers/github/sensors/test_github.py index 8ae5956bc34e1..3b70daeab8f3b 100644 --- a/tests/providers/github/sensors/test_github.py +++ b/tests/providers/github/sensors/test_github.py @@ -19,11 +19,16 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.models.dag import DAG from airflow.providers.github.sensors.github import GithubTagSensor from airflow.utils import db, timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2017, 1, 1) github_client_mock = Mock(name="github_client_for_test") diff --git a/tests/providers/google/cloud/hooks/test_bigquery.py b/tests/providers/google/cloud/hooks/test_bigquery.py index 2c13d16f6712f..238be83badc56 100644 --- a/tests/providers/google/cloud/hooks/test_bigquery.py +++ b/tests/providers/google/cloud/hooks/test_bigquery.py @@ -74,6 +74,7 @@ def test_delegate_to_runtime_error(): BigQueryHook(gcp_conn_id="GCP_CONN_ID", delegate_to="delegate_to") +@pytest.mark.db_test class TestBigQueryHookMethods(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryConnection") @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook._authorize") @@ -1010,6 +1011,7 @@ def test_invalid_syntax(self, table_input, var_name, exception_message): split_tablename(table_input, default_project_id, var_name) +@pytest.mark.db_test class TestTableOperations(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.Table") @mock.patch("airflow.providers.google.cloud.hooks.bigquery.Client") @@ -1204,6 +1206,7 @@ def test_create_materialized_view(self, mock_bq_client, mock_table): ) +@pytest.mark.db_test class TestBigQueryCursor(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.get_service") @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.insert_job") @@ -1449,6 +1452,7 @@ def test_arraysize(self, mock_get_service): assert bq_cursor.arraysize == 10 +@pytest.mark.db_test class TestDatasetsOperations(_BigQueryBaseTestClass): def test_create_empty_dataset_no_dataset_id_err(self): with pytest.raises(ValueError, match=r"Please specify `datasetId`"): @@ -1645,6 +1649,7 @@ def test_update_dataset(self, mock_client, mock_dataset): assert result == dataset +@pytest.mark.db_test class TestTimePartitioningInRunJob(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.insert_job") def test_run_load_default(self, mock_insert): @@ -1731,6 +1736,7 @@ def test_extra_time_partitioning_options(self): assert tp_out == expect +@pytest.mark.db_test class TestClusteringInRunJob(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.insert_job") def test_run_load_default(self, mock_insert): @@ -1776,6 +1782,7 @@ def test_run_query_with_arg(self, mock_insert): assert kwargs["configuration"]["query"]["clustering"] == {"fields": ["field1", "field2"]} +@pytest.mark.db_test class TestBigQueryHookLegacySql(_BigQueryBaseTestClass): """Ensure `use_legacy_sql` param in `BigQueryHook` propagates properly.""" @@ -1801,6 +1808,7 @@ def test_legacy_sql_override_propagates_properly( assert kwargs["configuration"]["query"]["useLegacySql"] is False +@pytest.mark.db_test class TestBigQueryHookRunWithConfiguration(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.LoadJob") @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.get_client") @@ -1823,6 +1831,7 @@ def test_run_with_configuration_location(self, mock_client, mock_job): ) +@pytest.mark.db_test class TestBigQueryWithKMS(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.Table") @mock.patch("airflow.providers.google.cloud.hooks.bigquery.Client") @@ -2067,6 +2076,7 @@ def test_deprecation_warning(self, mock_bq_hook, func_name): assert re.search(f".*:func:`~{new_path}`.*", func.__doc__) +@pytest.mark.db_test class TestBigQueryWithLabelsAndDescription(_BigQueryBaseTestClass): @mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.insert_job") def test_run_load_labels(self, mock_insert): @@ -2131,6 +2141,7 @@ def get_credentials_and_project_id(self): class TestBigQueryAsyncHookMethods(_BigQueryBaseAsyncTestClass): + @pytest.mark.db_test @pytest.mark.asyncio @mock.patch("airflow.providers.google.cloud.hooks.bigquery.ClientSession") async def test_get_job_instance(self, mock_session): @@ -2302,6 +2313,7 @@ def test_convert_to_float_if_possible(self, test_input, expected): assert BigQueryAsyncHook._convert_to_float_if_possible(test_input) == expected + @pytest.mark.db_test @pytest.mark.asyncio @mock.patch("aiohttp.client.ClientSession") async def test_get_table_client(self, mock_session): diff --git a/tests/providers/google/cloud/hooks/test_bigquery_dts.py b/tests/providers/google/cloud/hooks/test_bigquery_dts.py index 8beb54bc1b691..e9f0d266f7f77 100644 --- a/tests/providers/google/cloud/hooks/test_bigquery_dts.py +++ b/tests/providers/google/cloud/hooks/test_bigquery_dts.py @@ -153,6 +153,7 @@ def mock_client(self): def hook(self): return AsyncBiqQueryDataTransferServiceHook() + @pytest.mark.db_test @pytest.mark.asyncio async def test_get_transfer_run(self, mock_client, hook): await hook.get_transfer_run( diff --git a/tests/providers/google/cloud/hooks/test_cloud_batch.py b/tests/providers/google/cloud/hooks/test_cloud_batch.py index 5499935a5234f..de83b64fbe799 100644 --- a/tests/providers/google/cloud/hooks/test_cloud_batch.py +++ b/tests/providers/google/cloud/hooks/test_cloud_batch.py @@ -27,6 +27,8 @@ from airflow.providers.google.cloud.hooks.cloud_batch import CloudBatchAsyncHook, CloudBatchHook from tests.providers.google.cloud.utils.base_gcp_mock import mock_base_gcp_hook_default_project_id +pytestmark = pytest.mark.db_test + class TestCloudBathHook: def dummy_get_credentials(self): diff --git a/tests/providers/google/cloud/hooks/test_cloud_build.py b/tests/providers/google/cloud/hooks/test_cloud_build.py index 4e46a9ff1e643..4e247a9cd072c 100644 --- a/tests/providers/google/cloud/hooks/test_cloud_build.py +++ b/tests/providers/google/cloud/hooks/test_cloud_build.py @@ -349,6 +349,7 @@ def test_update_build_trigger(self, get_conn): ) +@pytest.mark.db_test class TestAsyncHook: def test_delegate_to_runtime_error(self): with pytest.raises(RuntimeError): diff --git a/tests/providers/google/cloud/hooks/test_cloud_run.py b/tests/providers/google/cloud/hooks/test_cloud_run.py index 6a9a4fa89870c..0a1436075e0aa 100644 --- a/tests/providers/google/cloud/hooks/test_cloud_run.py +++ b/tests/providers/google/cloud/hooks/test_cloud_run.py @@ -34,6 +34,7 @@ from tests.providers.google.cloud.utils.base_gcp_mock import mock_base_gcp_hook_default_project_id +@pytest.mark.db_test class TestCloudRunHook: def dummy_get_credentials(self): pass diff --git a/tests/providers/google/cloud/hooks/test_compute_ssh.py b/tests/providers/google/cloud/hooks/test_compute_ssh.py index 7c1b3a3178b9d..d79f73ce933ab 100644 --- a/tests/providers/google/cloud/hooks/test_compute_ssh.py +++ b/tests/providers/google/cloud/hooks/test_compute_ssh.py @@ -29,6 +29,9 @@ from airflow.models import Connection from airflow.providers.google.cloud.hooks.compute_ssh import ComputeEngineSSHHook +pytestmark = pytest.mark.db_test + + TEST_PROJECT_ID = "test-project-id" TEST_INSTANCE_NAME = "test-instance" diff --git a/tests/providers/google/cloud/hooks/test_dataflow.py b/tests/providers/google/cloud/hooks/test_dataflow.py index 4f6f2f8b740a4..aeaaabccb3b6c 100644 --- a/tests/providers/google/cloud/hooks/test_dataflow.py +++ b/tests/providers/google/cloud/hooks/test_dataflow.py @@ -176,6 +176,7 @@ def test_fn(self, *args, **kwargs): FixtureFallback().test_fn({"project": "TEST"}, "TEST2") +@pytest.mark.db_test class TestDataflowHook: def test_delegate_to_runtime_error(self): with pytest.raises(RuntimeError): @@ -819,6 +820,7 @@ def test_wait_for_done(self, mock_conn, mock_dataflowjob): method_wait_for_done.assert_called_once_with() +@pytest.mark.db_test class TestDataflowTemplateHook: def setup_method(self): self.dataflow_hook = DataflowHook(gcp_conn_id="google_cloud_default") diff --git a/tests/providers/google/cloud/hooks/test_dataform.py b/tests/providers/google/cloud/hooks/test_dataform.py index 02169c07147e1..9af2c9b724508 100644 --- a/tests/providers/google/cloud/hooks/test_dataform.py +++ b/tests/providers/google/cloud/hooks/test_dataform.py @@ -24,6 +24,9 @@ from airflow.providers.google.cloud.hooks.dataform import DataformHook from tests.providers.google.cloud.utils.base_gcp_mock import mock_base_gcp_hook_default_project_id +pytestmark = pytest.mark.db_test + + BASE_STRING = "airflow.providers.google.common.hooks.base_google.{}" DATAFORM_STRING = "airflow.providers.google.cloud.hooks.dataform.{}" diff --git a/tests/providers/google/cloud/hooks/test_datapipeline.py b/tests/providers/google/cloud/hooks/test_datapipeline.py index f636d20de2d81..728ba575e850f 100644 --- a/tests/providers/google/cloud/hooks/test_datapipeline.py +++ b/tests/providers/google/cloud/hooks/test_datapipeline.py @@ -19,8 +19,13 @@ from unittest import mock +import pytest + from airflow.providers.google.cloud.hooks.datapipeline import DataPipelineHook +pytestmark = pytest.mark.db_test + + TASK_ID = "test-datapipeline-operators" TEST_NAME = "projects/test-project-id/locations/test-location" TEST_BODY = { diff --git a/tests/providers/google/cloud/hooks/test_dataproc.py b/tests/providers/google/cloud/hooks/test_dataproc.py index c340d5b02d74e..c6eb6dcab3577 100644 --- a/tests/providers/google/cloud/hooks/test_dataproc.py +++ b/tests/providers/google/cloud/hooks/test_dataproc.py @@ -761,6 +761,7 @@ async def test_instantiate_workflow_template(self, mock_client): metadata=(), ) + @pytest.mark.db_test @pytest.mark.asyncio @mock.patch(DATAPROC_STRING.format("DataprocAsyncHook.get_operation")) async def test_get_operation(self, mock_client): diff --git a/tests/providers/google/cloud/hooks/test_gcs.py b/tests/providers/google/cloud/hooks/test_gcs.py index 38834d12399ee..ed767b05229df 100644 --- a/tests/providers/google/cloud/hooks/test_gcs.py +++ b/tests/providers/google/cloud/hooks/test_gcs.py @@ -504,6 +504,7 @@ def test_delete_bucket(self, mock_service): mock_service.return_value.bucket.assert_called_once_with(test_bucket, user_project=None) mock_service.return_value.bucket.return_value.delete.assert_called_once() + @pytest.mark.db_test @mock.patch(GCS_STRING.format("GCSHook.get_conn")) def test_delete_nonexisting_bucket(self, mock_service, caplog): mock_service.return_value.bucket.return_value.delete.side_effect = exceptions.NotFound( diff --git a/tests/providers/google/cloud/hooks/test_kubernetes_engine.py b/tests/providers/google/cloud/hooks/test_kubernetes_engine.py index f7cc7f3e4dc80..c226c0b98ebfe 100644 --- a/tests/providers/google/cloud/hooks/test_kubernetes_engine.py +++ b/tests/providers/google/cloud/hooks/test_kubernetes_engine.py @@ -51,6 +51,7 @@ OPERATION_NAME = "test-operation-name" +@pytest.mark.db_test class TestGKEHookClient: def test_delegate_to_runtime_error(self): with pytest.raises(RuntimeError): diff --git a/tests/providers/google/cloud/hooks/test_mlengine.py b/tests/providers/google/cloud/hooks/test_mlengine.py index 415e466754f6e..5798443bc15b8 100644 --- a/tests/providers/google/cloud/hooks/test_mlengine.py +++ b/tests/providers/google/cloud/hooks/test_mlengine.py @@ -41,6 +41,7 @@ pytest.JOB_ID = "test-job-id" +@pytest.mark.db_test class TestMLEngineHook: def test_delegate_to_runtime_error(self): with pytest.raises(RuntimeError): diff --git a/tests/providers/google/cloud/hooks/test_stackdriver.py b/tests/providers/google/cloud/hooks/test_stackdriver.py index 9fdf1859aaa04..fc30c2312e9bc 100644 --- a/tests/providers/google/cloud/hooks/test_stackdriver.py +++ b/tests/providers/google/cloud/hooks/test_stackdriver.py @@ -81,6 +81,7 @@ } +@pytest.mark.db_test class TestStackdriverHookMethods: def test_delegate_to_runtime_error(self): with pytest.raises(RuntimeError): diff --git a/tests/providers/google/cloud/log/test_gcs_task_handler.py b/tests/providers/google/cloud/log/test_gcs_task_handler.py index 95cbcb81fbd96..68b45e9b9fa20 100644 --- a/tests/providers/google/cloud/log/test_gcs_task_handler.py +++ b/tests/providers/google/cloud/log/test_gcs_task_handler.py @@ -31,6 +31,7 @@ from tests.test_utils.db import clear_db_dags, clear_db_runs +@pytest.mark.db_test class TestGCSTaskHandler: @pytest.fixture(autouse=True) def task_instance(self, create_task_instance): diff --git a/tests/providers/google/cloud/log/test_stackdriver_task_handler.py b/tests/providers/google/cloud/log/test_stackdriver_task_handler.py index cb240b70096e3..929fd8ab594a8 100644 --- a/tests/providers/google/cloud/log/test_stackdriver_task_handler.py +++ b/tests/providers/google/cloud/log/test_stackdriver_task_handler.py @@ -67,6 +67,7 @@ def test_should_pass_message_to_client(mock_client, mock_get_creds_and_project_i mock_client.assert_called_once_with(credentials="creds", client_info=mock.ANY, project="project_id") +@pytest.mark.db_test class TestStackdriverLoggingHandlerTask: DAG_ID = "dag_for_testing_stackdriver_file_task_handler" TASK_ID = "task_for_testing_stackdriver_task_handler" diff --git a/tests/providers/google/cloud/operators/test_bigquery.py b/tests/providers/google/cloud/operators/test_bigquery.py index 378508da0ef33..9aea410e78b02 100644 --- a/tests/providers/google/cloud/operators/test_bigquery.py +++ b/tests/providers/google/cloud/operators/test_bigquery.py @@ -65,6 +65,9 @@ from airflow.utils.timezone import datetime from tests.test_utils.db import clear_db_dags, clear_db_runs, clear_db_serialized_dags, clear_db_xcom +pytestmark = pytest.mark.db_test + + TASK_ID = "test-bq-generic-operator" TEST_DATASET = "test-dataset" TEST_DATASET_LOCATION = "EU" @@ -507,6 +510,7 @@ def test_execute(self, mock_hook): ) +@pytest.mark.db_test class TestBigQueryOperator: def teardown_method(self): clear_db_xcom() @@ -905,6 +909,7 @@ def test_generate_query__without_table_project_id(self, mock_hook): f"{TEST_DATASET}.{TEST_TABLE_ID}` limit 100" ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_get_data_operator_async_with_selected_fields( self, mock_hook, create_task_instance_of_operator @@ -933,6 +938,7 @@ def test_bigquery_get_data_operator_async_with_selected_fields( exc.value.trigger, BigQueryGetDataTrigger ), "Trigger is not a BigQueryGetDataTrigger" + @pytest.mark.db_test @pytest.mark.parametrize("as_dict", [True, False]) @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_get_data_operator_async_without_selected_fields( @@ -1432,6 +1438,7 @@ def test_bigquery_insert_job_operator_async_error_before_deferred(self, mock_hoo assert str(exc.value) == f"BigQuery job {real_job_id} failed: True" + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_insert_job_operator_async(self, mock_hook, create_task_instance_of_operator): """ @@ -1492,6 +1499,7 @@ def test_bigquery_insert_job_operator_execute_failure(self): context=None, event={"status": "error", "message": "test failure message"} ) + @pytest.mark.db_test def test_bigquery_insert_job_operator_execute_complete(self, create_task_instance_of_operator): """Asserts that logging occurs as expected""" configuration = { @@ -1522,6 +1530,7 @@ def test_bigquery_insert_job_operator_execute_complete(self, create_task_instanc "%s completed with response %s ", "insert_query_job", "Job completed" ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_insert_job_operator_with_job_id_generate( self, mock_hook, create_task_instance_of_operator @@ -1652,6 +1661,7 @@ def test_execute_fails_openlineage_events(self, mock_hook): assert lineage.run_facets == {"bigQuery_error": BigQueryErrorRunFacet(clientError=mock.ANY)} + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_execute_force_rerun_async(self, mock_hook, create_task_instance_of_operator): job_id = "123456" @@ -1739,6 +1749,7 @@ def test_bigquery_interval_check_operator_execute_failure(self): context=None, event={"status": "error", "message": "test failure message"} ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_interval_check_operator_async(self, mock_hook, create_task_instance_of_operator): """ @@ -1768,6 +1779,7 @@ def test_bigquery_interval_check_operator_async(self, mock_hook, create_task_ins exc.value.trigger, BigQueryIntervalCheckTrigger ), "Trigger is not a BigQueryIntervalCheckTrigger" + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_interval_check_operator_with_project_id( self, mock_hook, create_task_instance_of_operator @@ -1805,6 +1817,7 @@ def test_bigquery_interval_check_operator_with_project_id( nowait=True, ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_interval_check_operator_without_project_id( self, mock_hook, create_task_instance_of_operator @@ -1844,6 +1857,7 @@ def test_bigquery_interval_check_operator_without_project_id( class TestBigQueryCheckOperator: + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryCheckOperator.execute") @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryCheckOperator.defer") @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") @@ -1870,6 +1884,7 @@ def test_bigquery_check_operator_async_finish_before_deferred( assert not mock_defer.called assert mock_execute.called + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_check_operator_async(self, mock_hook, create_task_instance_of_operator): """ @@ -1963,6 +1978,7 @@ def test_bigquery_check_operator_execute_complete(self): class TestBigQueryValueCheckOperator: + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") def test_bigquery_value_check_async(self, mock_hook, create_task_instance_of_operator): """ @@ -1989,6 +2005,7 @@ def test_bigquery_value_check_async(self, mock_hook, create_task_instance_of_ope exc.value.trigger, BigQueryValueCheckTrigger ), "Trigger is not a BigQueryValueCheckTrigger" + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryValueCheckOperator.defer") @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryValueCheckOperator.check_value") @mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook") @@ -2074,6 +2091,7 @@ def test_bigquery_value_check_operator_execute_complete_failure(self): ) +@pytest.mark.db_test class TestBigQueryColumnCheckOperator: @pytest.mark.parametrize( "check_type, check_value, check_result", diff --git a/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py b/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py index 4adf99be18ec0..e3318991bc96a 100644 --- a/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py +++ b/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py @@ -323,6 +323,7 @@ def test_job_create_multiple(self, aws_hook, gcp_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -369,6 +370,7 @@ def test_job_update(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -410,6 +412,7 @@ def test_job_delete(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -463,6 +466,7 @@ def test_operation_get(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -512,6 +516,7 @@ def test_operation_list(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -551,6 +556,7 @@ def test_operation_pause(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -605,6 +611,7 @@ def test_operation_resume(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -659,6 +666,7 @@ def test_operation_cancel(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -710,6 +718,7 @@ def test_constructor(self): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) @@ -862,6 +871,7 @@ def test_constructor(self): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all # fields + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.cloud_storage_transfer_service.CloudDataTransferServiceHook" ) diff --git a/tests/providers/google/cloud/operators/test_compute.py b/tests/providers/google/cloud/operators/test_compute.py index 2ad1d5bddd408..c75bed833a5e3 100644 --- a/tests/providers/google/cloud/operators/test_compute.py +++ b/tests/providers/google/cloud/operators/test_compute.py @@ -557,6 +557,7 @@ def test_start_instance_should_execute_successfully(self, mock_hook): # Setting all the operator's input parameters as template dag_ids # (could be anything else) just to test if the templating works for all fields + @pytest.mark.db_test @mock.patch(COMPUTE_ENGINE_HOOK_PATH) def test_start_instance_with_templates(self, _, create_task_instance_of_operator): dag_id = "test_instance_start_with_templates" @@ -659,6 +660,7 @@ def test_instance_stop_should_execute_successfully(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all fields + @pytest.mark.db_test @mock.patch(COMPUTE_ENGINE_HOOK_PATH) def test_instance_stop_with_templates(self, _, create_task_instance_of_operator): dag_id = "test_instance_stop_with_templates" @@ -750,6 +752,7 @@ def test_machine_type_set_should_execute_successfully(self, mock_hook): # Setting all the operator's input parameters as templated dag_ids # (could be anything else) just to test if the templating works for all fields + @pytest.mark.db_test @mock.patch(COMPUTE_ENGINE_HOOK_PATH) def test_machine_type_set_with_templates(self, _, create_task_instance_of_operator): dag_id = "test_set_machine_type_with_templates" @@ -879,6 +882,7 @@ def test_machine_type_set_should_throw_ex_when_missing_machine_type(self, mock_h "-577542784f769-7999ab71-94f9ec1d'} " ) + @pytest.mark.db_test @mock.patch( "airflow.providers.google.cloud.operators.compute.ComputeEngineHook._check_zone_operation_status" ) diff --git a/tests/providers/google/cloud/operators/test_dataflow.py b/tests/providers/google/cloud/operators/test_dataflow.py index 8c0970b55c44c..eacd5fde5ba21 100644 --- a/tests/providers/google/cloud/operators/test_dataflow.py +++ b/tests/providers/google/cloud/operators/test_dataflow.py @@ -536,6 +536,7 @@ def test_validation_deferrable_params_raises_error(self): with pytest.raises(ValueError): DataflowTemplatedJobStartOperator(**init_kwargs) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.dataflow.DataflowHook.start_template_dataflow") def test_start_with_custom_region(self, dataflow_mock): init_kwargs = { @@ -555,6 +556,7 @@ def test_start_with_custom_region(self, dataflow_mock): assert kwargs["variables"]["region"] == TEST_REGION assert kwargs["location"] is None + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.dataflow.DataflowHook.start_template_dataflow") def test_start_with_location(self, dataflow_mock): init_kwargs = { diff --git a/tests/providers/google/cloud/operators/test_dataprep.py b/tests/providers/google/cloud/operators/test_dataprep.py index d5800716a8716..acbbf2063bfa5 100644 --- a/tests/providers/google/cloud/operators/test_dataprep.py +++ b/tests/providers/google/cloud/operators/test_dataprep.py @@ -172,6 +172,7 @@ def test_execute_with_specified_params(self, hook_mock): flow_id=FLOW_ID, name="specified name", description="specified description", copy_datasources=True ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.dataprep.GoogleDataprepHook") def test_execute_with_templated_params(self, _, create_task_instance_of_operator): dag_id = "test_execute_with_templated_params" @@ -245,6 +246,7 @@ def test_execute(self, hook_mock): flow_id=FLOW_ID, ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.dataprep.GoogleDataprepHook") def test_execute_with_template_params(self, _, create_task_instance_of_operator): dag_id = "test_execute_delete_flow_with_template" @@ -275,6 +277,7 @@ def test_execute(self, hook_mock): body_request={}, ) + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.operators.dataprep.GoogleDataprepHook") def test_execute_with_template_params(self, _, create_task_instance_of_operator): dag_id = "test_execute_run_flow_with_template" diff --git a/tests/providers/google/cloud/operators/test_dataproc.py b/tests/providers/google/cloud/operators/test_dataproc.py index 02620ccb6c7b2..0f731210c622a 100644 --- a/tests/providers/google/cloud/operators/test_dataproc.py +++ b/tests/providers/google/cloud/operators/test_dataproc.py @@ -744,6 +744,7 @@ def test_create_execute_call_defer_method(self, mock_trigger_hook, mock_hook): assert exc.value.method_name == GOOGLE_DEFAULT_DEFERRABLE_METHOD_NAME +@pytest.mark.db_test @pytest.mark.need_serialized_dag def test_create_cluster_operator_extra_links(dag_maker, create_task_instance_of_operator): ti = create_task_instance_of_operator( @@ -843,6 +844,7 @@ def test_execute(self, mock_hook): ) +@pytest.mark.db_test @pytest.mark.need_serialized_dag def test_scale_cluster_operator_extra_links(dag_maker, create_task_instance_of_operator): ti = create_task_instance_of_operator( @@ -1199,6 +1201,7 @@ def test_missing_region_parameter(self, mock_hook): op.execute(context=self.mock_context) +@pytest.mark.db_test @pytest.mark.need_serialized_dag @mock.patch(DATAPROC_PATH.format("DataprocHook")) def test_submit_job_operator_extra_links(mock_hook, dag_maker, create_task_instance_of_operator): @@ -1356,6 +1359,7 @@ def test_create_execute_call_defer_method(self, mock_trigger_hook, mock_hook): assert exc.value.method_name == GOOGLE_DEFAULT_DEFERRABLE_METHOD_NAME +@pytest.mark.db_test @pytest.mark.need_serialized_dag def test_update_cluster_operator_extra_links(dag_maker, create_task_instance_of_operator): ti = create_task_instance_of_operator( @@ -1495,6 +1499,7 @@ def test_on_kill(self, mock_hook): ) +@pytest.mark.db_test @pytest.mark.need_serialized_dag @mock.patch(DATAPROC_PATH.format("DataprocHook")) def test_instantiate_workflow_operator_extra_links(mock_hook, dag_maker, create_task_instance_of_operator): @@ -1624,6 +1629,7 @@ def test_on_kill(self, mock_hook): ) +@pytest.mark.db_test @pytest.mark.need_serialized_dag @mock.patch(DATAPROC_PATH.format("DataprocHook")) def test_instantiate_inline_workflow_operator_extra_links( @@ -1944,6 +1950,7 @@ def test_execute(self, mock_hook, mock_uuid): self.extra_links_manager_mock.assert_has_calls(self.extra_links_expected_calls, any_order=False) +@pytest.mark.db_test @pytest.mark.need_serialized_dag @mock.patch(DATAPROC_PATH.format("DataprocHook")) def test_submit_spark_job_operator_extra_links(mock_hook, dag_maker, create_task_instance_of_operator): diff --git a/tests/providers/google/cloud/operators/test_functions.py b/tests/providers/google/cloud/operators/test_functions.py index 18f2364c918d0..eb23e3be40eb4 100644 --- a/tests/providers/google/cloud/operators/test_functions.py +++ b/tests/providers/google/cloud/operators/test_functions.py @@ -293,6 +293,7 @@ def test_invalid_field_values(self, mock_hook, key, value, message): ) mock_hook.reset_mock() + @pytest.mark.db_test @pytest.mark.parametrize( "source_code, message", [ diff --git a/tests/providers/google/cloud/operators/test_kubernetes_engine.py b/tests/providers/google/cloud/operators/test_kubernetes_engine.py index 328da500b68e4..5f91fd9e4ea99 100644 --- a/tests/providers/google/cloud/operators/test_kubernetes_engine.py +++ b/tests/providers/google/cloud/operators/test_kubernetes_engine.py @@ -295,6 +295,7 @@ def test_execute_with_impersonation_service_chain_one_element( fetch_cluster_info_mock.assert_called_once() + @pytest.mark.db_test @pytest.mark.parametrize("use_internal_ip", [True, False]) @mock.patch(f"{GKE_HOOK_PATH}.get_cluster") def test_cluster_info(self, get_cluster_mock, use_internal_ip): @@ -320,6 +321,7 @@ def test_cluster_info(self, get_cluster_mock, use_internal_ip): assert cluster_url == CLUSTER_PRIVATE_URL if use_internal_ip else CLUSTER_URL assert ssl_ca_cert == SSL_CA_CERT + @pytest.mark.db_test def test_default_gcp_conn_id(self): gke_op = GKEStartPodOperator( project_id=TEST_GCP_PROJECT_ID, diff --git a/tests/providers/google/cloud/secrets/test_secret_manager.py b/tests/providers/google/cloud/secrets/test_secret_manager.py index 9636d69308066..c6a06adf4cf68 100644 --- a/tests/providers/google/cloud/secrets/test_secret_manager.py +++ b/tests/providers/google/cloud/secrets/test_secret_manager.py @@ -28,6 +28,8 @@ from airflow.models import Connection from airflow.providers.google.cloud.secrets.secret_manager import CloudSecretManagerBackend +pytestmark = pytest.mark.db_test + CREDENTIALS = "test-creds" KEY_FILE = "test-file.json" PROJECT_ID = "test-project-id" diff --git a/tests/providers/google/cloud/sensors/test_cloud_composer.py b/tests/providers/google/cloud/sensors/test_cloud_composer.py index f6f3e81a4019b..5241ff551e634 100644 --- a/tests/providers/google/cloud/sensors/test_cloud_composer.py +++ b/tests/providers/google/cloud/sensors/test_cloud_composer.py @@ -31,6 +31,7 @@ class TestCloudComposerEnvironmentSensor: + @pytest.mark.db_test def test_cloud_composer_existence_sensor_async(self): """ Asserts that a task is deferred and a CloudComposerExecutionTrigger will be fired diff --git a/tests/providers/google/cloud/transfers/test_cassandra_to_gcs.py b/tests/providers/google/cloud/transfers/test_cassandra_to_gcs.py index 56b47f34b2f51..68a3155cf3a2e 100644 --- a/tests/providers/google/cloud/transfers/test_cassandra_to_gcs.py +++ b/tests/providers/google/cloud/transfers/test_cassandra_to_gcs.py @@ -20,6 +20,8 @@ from unittest import mock from unittest.mock import call +import pytest + from airflow.providers.google.cloud.transfers.cassandra_to_gcs import CassandraToGCSOperator TMP_FILE_NAME = "temp-file" @@ -31,6 +33,7 @@ class TestCassandraToGCS: + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.transfers.cassandra_to_gcs.NamedTemporaryFile") @mock.patch("airflow.providers.google.cloud.transfers.cassandra_to_gcs.GCSHook.upload") @mock.patch("airflow.providers.google.cloud.transfers.cassandra_to_gcs.CassandraHook") diff --git a/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py b/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py index 1a0f38183754d..a67759ff85d1e 100644 --- a/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py +++ b/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py @@ -1264,6 +1264,7 @@ def test_execute_without_external_table_async_should_throw_ex_when_event_status_ context=None, event={"status": "error", "message": "test failure message"} ) + @pytest.mark.db_test def test_execute_logging_without_external_table_async_should_execute_successfully(self): """ Asserts that logging occurs as expected. diff --git a/tests/providers/google/cloud/transfers/test_local_to_gcs.py b/tests/providers/google/cloud/transfers/test_local_to_gcs.py index eb1717d72227f..9f046b20b2b0e 100644 --- a/tests/providers/google/cloud/transfers/test_local_to_gcs.py +++ b/tests/providers/google/cloud/transfers/test_local_to_gcs.py @@ -27,6 +27,8 @@ from airflow.models.dag import DAG from airflow.providers.google.cloud.transfers.local_to_gcs import LocalFilesystemToGCSOperator +pytestmark = pytest.mark.db_test + class TestFileToGcsOperator: _config = {"bucket": "dummy", "mime_type": "application/octet-stream", "gzip": False} @@ -79,6 +81,7 @@ def test_execute(self, mock_hook): object_name="test/test1.csv", ) + @pytest.mark.db_test def test_execute_with_empty_src(self): operator = LocalFilesystemToGCSOperator( task_id="local_to_sensor", diff --git a/tests/providers/google/cloud/transfers/test_s3_to_gcs.py b/tests/providers/google/cloud/transfers/test_s3_to_gcs.py index df12a41b66e8c..896d281d32891 100644 --- a/tests/providers/google/cloud/transfers/test_s3_to_gcs.py +++ b/tests/providers/google/cloud/transfers/test_s3_to_gcs.py @@ -479,6 +479,7 @@ def test_execute_complete_error(self, mock_log): mock_log.return_value.info.assert_not_called() + @pytest.mark.db_test def test_get_transfer_hook(self): operator = S3ToGCSOperator( task_id=TASK_ID, diff --git a/tests/providers/google/cloud/transfers/test_salesforce_to_gcs.py b/tests/providers/google/cloud/transfers/test_salesforce_to_gcs.py index 149fee29fa319..7d4a6b2d6efb6 100644 --- a/tests/providers/google/cloud/transfers/test_salesforce_to_gcs.py +++ b/tests/providers/google/cloud/transfers/test_salesforce_to_gcs.py @@ -18,6 +18,8 @@ from unittest import mock +import pytest + from airflow.providers.google.cloud.hooks.gcs import GCSHook from airflow.providers.google.cloud.transfers.salesforce_to_gcs import SalesforceToGcsOperator from airflow.providers.salesforce.hooks.salesforce import SalesforceHook @@ -45,6 +47,7 @@ class TestSalesforceToGcsOperator: + @pytest.mark.db_test @mock.patch.object(GCSHook, "upload") @mock.patch.object(SalesforceHook, "write_object_to_file") @mock.patch.object(SalesforceHook, "make_query") diff --git a/tests/providers/google/cloud/transfers/test_sql_to_gcs.py b/tests/providers/google/cloud/transfers/test_sql_to_gcs.py index 6a66ac2733cab..ea7a3defd3f0a 100644 --- a/tests/providers/google/cloud/transfers/test_sql_to_gcs.py +++ b/tests/providers/google/cloud/transfers/test_sql_to_gcs.py @@ -85,6 +85,7 @@ def query(self): class TestBaseSQLToGCSOperator: + @pytest.mark.db_test @mock.patch("airflow.providers.google.cloud.transfers.sql_to_gcs.NamedTemporaryFile") @mock.patch("csv.writer") @mock.patch.object(GCSHook, "upload") diff --git a/tests/providers/google/cloud/triggers/test_bigquery.py b/tests/providers/google/cloud/triggers/test_bigquery.py index 81309161b0018..1611c8e3e0d77 100644 --- a/tests/providers/google/cloud/triggers/test_bigquery.py +++ b/tests/providers/google/cloud/triggers/test_bigquery.py @@ -40,6 +40,9 @@ ) from airflow.triggers.base import TriggerEvent +pytestmark = pytest.mark.db_test + + TEST_CONN_ID = "bq_default" TEST_JOB_ID = "1234" TEST_GCP_PROJECT_ID = "test-project" diff --git a/tests/providers/google/cloud/triggers/test_dataproc.py b/tests/providers/google/cloud/triggers/test_dataproc.py index b107b6021724d..6f5e2782adad2 100644 --- a/tests/providers/google/cloud/triggers/test_dataproc.py +++ b/tests/providers/google/cloud/triggers/test_dataproc.py @@ -120,6 +120,7 @@ def func(**kwargs): return func +@pytest.mark.db_test class TestDataprocClusterTrigger: def test_async_cluster_trigger_serialization_should_execute_successfully(self, cluster_trigger): classpath, kwargs = cluster_trigger.serialize() @@ -203,6 +204,7 @@ async def test_cluster_run_loop_is_still_running( assert f"Sleeping for {TEST_POLL_INTERVAL} seconds." +@pytest.mark.db_test class TestDataprocBatchTrigger: def test_async_create_batch_trigger_serialization_should_execute_successfully(self, batch_trigger): """ diff --git a/tests/providers/google/cloud/triggers/test_kubernetes_engine.py b/tests/providers/google/cloud/triggers/test_kubernetes_engine.py index cf202cb22cee3..41f0a67211fc2 100644 --- a/tests/providers/google/cloud/triggers/test_kubernetes_engine.py +++ b/tests/providers/google/cloud/triggers/test_kubernetes_engine.py @@ -314,6 +314,7 @@ def func(**kwargs): return func +@pytest.mark.db_test class TestGKEOperationTrigger: def test_serialize(self, operation_trigger): classpath, trigger_init_kwargs = operation_trigger.serialize() diff --git a/tests/providers/google/cloud/utils/test_credentials_provider.py b/tests/providers/google/cloud/utils/test_credentials_provider.py index 21976c6f6df43..fedea26cd8913 100644 --- a/tests/providers/google/cloud/utils/test_credentials_provider.py +++ b/tests/providers/google/cloud/utils/test_credentials_provider.py @@ -130,6 +130,7 @@ def test_provide_gcp_conn_and_credentials(self, mock_builder): assert os.environ[CREDENTIALS] == ENV_VALUE +@pytest.mark.db_test class TestGetGcpCredentialsAndProjectId: test_scopes = _DEFAULT_SCOPES test_key_file = "KEY_PATH.json" diff --git a/tests/providers/google/cloud/utils/test_mlengine_operator_utils.py b/tests/providers/google/cloud/utils/test_mlengine_operator_utils.py index 3460e3a28381e..8d468143a6b07 100644 --- a/tests/providers/google/cloud/utils/test_mlengine_operator_utils.py +++ b/tests/providers/google/cloud/utils/test_mlengine_operator_utils.py @@ -226,6 +226,7 @@ def test_create_evaluate_ops_dag(self, mock_dataflow, mock_python): assert TASK_PREFIX_VALIDATION == evaluate_validation.task_id assert PREDICTION_PATH == evaluate_validation.templates_dict["prediction_path"] + @pytest.mark.db_test @mock.patch.object(GCSHook, "download") @mock.patch.object(PythonOperator, "set_upstream") @mock.patch.object(BeamRunPythonPipelineOperator, "set_upstream") diff --git a/tests/providers/google/common/auth_backend/test_google_openid.py b/tests/providers/google/common/auth_backend/test_google_openid.py index 8aa77f61877e2..d11613b5cf9f3 100644 --- a/tests/providers/google/common/auth_backend/test_google_openid.py +++ b/tests/providers/google/common/auth_backend/test_google_openid.py @@ -54,6 +54,7 @@ def admin_user(google_openid_app): return role_admin +@pytest.mark.db_test class TestGoogleOpenID: @pytest.fixture(autouse=True) def _set_attrs(self, google_openid_app, admin_user) -> None: diff --git a/tests/providers/google/common/hooks/test_base_google.py b/tests/providers/google/common/hooks/test_base_google.py index 897e2f08fd8b4..06d04f63187b1 100644 --- a/tests/providers/google/common/hooks/test_base_google.py +++ b/tests/providers/google/common/hooks/test_base_google.py @@ -352,6 +352,7 @@ def test_provide_gcp_credential_keep_clear_environment_when_exception(self): assert CREDENTIALS not in os.environ +@pytest.mark.db_test class TestGoogleBaseHook: def setup_method(self): self.instance = hook.GoogleBaseHook() @@ -824,6 +825,7 @@ def test_provide_authorized_gcloud_via_gcloud_application_default( class TestNumRetry: + @pytest.mark.db_test def test_should_return_int_when_set_int_via_connection(self): instance = hook.GoogleBaseHook(gcp_conn_id="google_cloud_default") instance.extras = { diff --git a/tests/providers/google/common/hooks/test_discovery_api.py b/tests/providers/google/common/hooks/test_discovery_api.py index 148d8d60ec587..7e9d88df500a2 100644 --- a/tests/providers/google/common/hooks/test_discovery_api.py +++ b/tests/providers/google/common/hooks/test_discovery_api.py @@ -19,11 +19,15 @@ from unittest.mock import call, patch +import pytest + from airflow import models from airflow.configuration import conf from airflow.providers.google.common.hooks.discovery_api import GoogleDiscoveryApiHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestGoogleDiscoveryApiHook: def setup_method(self): diff --git a/tests/providers/google/marketing_platform/operators/test_campaign_manager.py b/tests/providers/google/marketing_platform/operators/test_campaign_manager.py index adb38369bb4db..258ee92f91b1d 100644 --- a/tests/providers/google/marketing_platform/operators/test_campaign_manager.py +++ b/tests/providers/google/marketing_platform/operators/test_campaign_manager.py @@ -86,6 +86,7 @@ def test_execute(self, mock_base_op, hook_mock): ) +@pytest.mark.db_test class TestGoogleCampaignManagerDownloadReportOperator: def setup_method(self): with create_session() as session: diff --git a/tests/providers/google/marketing_platform/operators/test_display_video.py b/tests/providers/google/marketing_platform/operators/test_display_video.py index 0e5dc190a5d00..66b3ddd80932d 100644 --- a/tests/providers/google/marketing_platform/operators/test_display_video.py +++ b/tests/providers/google/marketing_platform/operators/test_display_video.py @@ -68,6 +68,7 @@ def test_execute(self, hook_mock): hook_mock.return_value.delete_query.assert_called_once_with(query_id=QUERY_ID) +@pytest.mark.db_test class TestGoogleDisplayVideo360DownloadReportV2Operator: def setup_method(self): with create_session() as session: diff --git a/tests/providers/google/marketing_platform/operators/test_search_ads.py b/tests/providers/google/marketing_platform/operators/test_search_ads.py index 0698d9fd3dc08..a168854d0a34b 100644 --- a/tests/providers/google/marketing_platform/operators/test_search_ads.py +++ b/tests/providers/google/marketing_platform/operators/test_search_ads.py @@ -77,6 +77,7 @@ def test_prepare_template(self): assert op.report == report +@pytest.mark.db_test class TestGoogleSearchAdsDownloadReportOperator: def setup_method(self): with create_session() as session: diff --git a/tests/providers/google/marketing_platform/sensors/test_search_ads.py b/tests/providers/google/marketing_platform/sensors/test_search_ads.py index 9c5312177e01d..e03b64a3c63c8 100644 --- a/tests/providers/google/marketing_platform/sensors/test_search_ads.py +++ b/tests/providers/google/marketing_platform/sensors/test_search_ads.py @@ -19,8 +19,12 @@ from unittest import mock +import pytest + from airflow.providers.google.marketing_platform.sensors.search_ads import GoogleSearchAdsReportSensor +pytestmark = pytest.mark.db_test + API_VERSION = "api_version" GCP_CONN_ID = "google_cloud_default" diff --git a/tests/providers/google/suite/hooks/test_drive.py b/tests/providers/google/suite/hooks/test_drive.py index 14f8ecf7ecf64..00423f263401c 100644 --- a/tests/providers/google/suite/hooks/test_drive.py +++ b/tests/providers/google/suite/hooks/test_drive.py @@ -19,10 +19,13 @@ from unittest import mock +import pytest + from airflow.providers.google.suite.hooks.drive import GoogleDriveHook from tests.providers.google.cloud.utils.base_gcp_mock import GCP_CONNECTION_WITH_PROJECT_ID +@pytest.mark.db_test class TestGoogleDriveHook: def setup_method(self): self.patcher_get_connection = mock.patch( diff --git a/tests/providers/http/hooks/test_http.py b/tests/providers/http/hooks/test_http.py index 345afa54dea8c..8b03b9ab1334f 100644 --- a/tests/providers/http/hooks/test_http.py +++ b/tests/providers/http/hooks/test_http.py @@ -131,10 +131,12 @@ def test_hook_with_method_in_lowercase(self, mock_requests): self.get_lowercase_hook.run("v1/test", data=data) mock_requests.assert_called_once_with(mock.ANY, mock.ANY, headers=mock.ANY, params=data) + @pytest.mark.db_test def test_hook_uses_provided_header(self): conn = self.get_hook.get_conn(headers={"bearer": "newT0k3n"}) assert conn.headers.get("bearer") == "newT0k3n" + @pytest.mark.db_test def test_hook_has_no_header_from_extra(self): conn = self.get_hook.get_conn() assert conn.headers.get("bearer") is None @@ -177,6 +179,7 @@ def test_post_request_do_not_raise_for_status_if_check_response_is_false(self, r resp = self.post_hook.run("v1/test", extra_options={"check_response": False}) assert resp.status_code == 418 + @pytest.mark.db_test @mock.patch("airflow.providers.http.hooks.http.requests.Session") def test_retry_on_conn_error(self, mocked_session): retry_args = dict( @@ -463,6 +466,7 @@ async def test_do_api_call_async_retryable_error(self, caplog, aioresponse): assert "[Try 3 of 3] Request to http://httpbin.org/non_existent_endpoint failed" in caplog.text + @pytest.mark.db_test @pytest.mark.asyncio async def test_do_api_call_async_unknown_method(self): """Test api call asynchronously for unknown http method.""" diff --git a/tests/providers/http/sensors/test_http.py b/tests/providers/http/sensors/test_http.py index b64a4cfdf4309..8fed2ecb32d93 100644 --- a/tests/providers/http/sensors/test_http.py +++ b/tests/providers/http/sensors/test_http.py @@ -29,6 +29,9 @@ from airflow.providers.http.sensors.http import HttpSensor from airflow.utils.timezone import datetime +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2015, 1, 1) DEFAULT_DATE_ISO = DEFAULT_DATE.isoformat() TEST_DAG_ID = "unit_test_dag" diff --git a/tests/providers/imap/hooks/test_imap.py b/tests/providers/imap/hooks/test_imap.py index 5f3c7e569e831..2430d3f664882 100644 --- a/tests/providers/imap/hooks/test_imap.py +++ b/tests/providers/imap/hooks/test_imap.py @@ -29,6 +29,9 @@ from airflow.utils import db from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + imaplib_string = "airflow.providers.imap.hooks.imap.imaplib" open_string = "airflow.providers.imap.hooks.imap.open" diff --git a/tests/providers/jdbc/hooks/test_jdbc.py b/tests/providers/jdbc/hooks/test_jdbc.py index 4374a0cad64e8..8b303db67e2fc 100644 --- a/tests/providers/jdbc/hooks/test_jdbc.py +++ b/tests/providers/jdbc/hooks/test_jdbc.py @@ -22,10 +22,15 @@ from unittest import mock from unittest.mock import Mock, patch +import pytest + from airflow.models import Connection from airflow.providers.jdbc.hooks.jdbc import JdbcHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + jdbc_conn_mock = Mock(name="jdbc_conn") diff --git a/tests/providers/microsoft/azure/hooks/test_adx.py b/tests/providers/microsoft/azure/hooks/test_adx.py index 646f80c1bff35..39b408af2cca7 100644 --- a/tests/providers/microsoft/azure/hooks/test_adx.py +++ b/tests/providers/microsoft/azure/hooks/test_adx.py @@ -29,6 +29,8 @@ ADX_TEST_CONN_ID = "adx_test_connection_id" +pytestmark = pytest.mark.db_test + class TestAzureDataExplorerHook: @pytest.mark.parametrize( diff --git a/tests/providers/microsoft/azure/hooks/test_base_azure.py b/tests/providers/microsoft/azure/hooks/test_base_azure.py index 53e2614a69a8f..313d61cd11153 100644 --- a/tests/providers/microsoft/azure/hooks/test_base_azure.py +++ b/tests/providers/microsoft/azure/hooks/test_base_azure.py @@ -23,6 +23,8 @@ from airflow.models import Connection from airflow.providers.microsoft.azure.hooks.base_azure import AzureBaseHook +pytestmark = pytest.mark.db_test + class TestBaseAzureHook: @pytest.mark.parametrize( diff --git a/tests/providers/microsoft/azure/hooks/test_wasb.py b/tests/providers/microsoft/azure/hooks/test_wasb.py index 971a8f188f9fa..5344091048565 100644 --- a/tests/providers/microsoft/azure/hooks/test_wasb.py +++ b/tests/providers/microsoft/azure/hooks/test_wasb.py @@ -27,6 +27,9 @@ from airflow.models import Connection from airflow.providers.microsoft.azure.hooks.wasb import WasbHook +pytestmark = pytest.mark.db_test + + # connection_string has a format CONN_STRING = ( "DefaultEndpointsProtocol=https;AccountName=testname;AccountKey=wK7BOz;EndpointSuffix=core.windows.net" diff --git a/tests/providers/microsoft/azure/log/test_wasb_task_handler.py b/tests/providers/microsoft/azure/log/test_wasb_task_handler.py index fe554bd1615e4..f86c5f71f165c 100644 --- a/tests/providers/microsoft/azure/log/test_wasb_task_handler.py +++ b/tests/providers/microsoft/azure/log/test_wasb_task_handler.py @@ -32,6 +32,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2020, 8, 10) diff --git a/tests/providers/microsoft/azure/operators/test_adx.py b/tests/providers/microsoft/azure/operators/test_adx.py index 82e48cd06749b..fc88e64d10289 100644 --- a/tests/providers/microsoft/azure/operators/test_adx.py +++ b/tests/providers/microsoft/azure/operators/test_adx.py @@ -19,6 +19,7 @@ from unittest import mock +import pytest from azure.kusto.data._models import KustoResultTable from airflow.models import DAG @@ -81,6 +82,7 @@ def test_run_query(self, mock_conn, mock_run_query): ) +@pytest.mark.db_test @mock.patch.object(AzureDataExplorerHook, "run_query", return_value=MockResponse()) @mock.patch.object(AzureDataExplorerHook, "get_conn") def test_azure_data_explorer_query_operator_xcom_push_and_pull( diff --git a/tests/providers/microsoft/azure/operators/test_azure_data_factory.py b/tests/providers/microsoft/azure/operators/test_azure_data_factory.py index 8baa3235fb1a7..66a83913b4ff8 100644 --- a/tests/providers/microsoft/azure/operators/test_azure_data_factory.py +++ b/tests/providers/microsoft/azure/operators/test_azure_data_factory.py @@ -218,6 +218,7 @@ def test_execute_no_wait_for_termination(self, mock_run_pipeline): # Checking the pipeline run status should _not_ be called when ``wait_for_termination`` is False. mock_get_pipeline_run.assert_not_called() + @pytest.mark.db_test @pytest.mark.parametrize( "resource_group,factory", [ diff --git a/tests/providers/microsoft/mssql/hooks/test_mssql.py b/tests/providers/microsoft/mssql/hooks/test_mssql.py index 6bffab744b1db..aeaf13ae02189 100644 --- a/tests/providers/microsoft/mssql/hooks/test_mssql.py +++ b/tests/providers/microsoft/mssql/hooks/test_mssql.py @@ -150,6 +150,7 @@ def test_sqlalchemy_scheme_is_default(self, get_connection): hook = MsSqlHook() assert hook.sqlalchemy_scheme == hook.DEFAULT_SQLALCHEMY_SCHEME + @pytest.mark.db_test def test_sqlalchemy_scheme_is_from_hook(self): hook = MsSqlHook(sqlalchemy_scheme="mssql+mytestdriver") assert hook.sqlalchemy_scheme == "mssql+mytestdriver" diff --git a/tests/providers/microsoft/winrm/hooks/test_winrm.py b/tests/providers/microsoft/winrm/hooks/test_winrm.py index 906ba91ccab4f..83411ccf9ccf2 100644 --- a/tests/providers/microsoft/winrm/hooks/test_winrm.py +++ b/tests/providers/microsoft/winrm/hooks/test_winrm.py @@ -25,6 +25,8 @@ from airflow.models import Connection from airflow.providers.microsoft.winrm.hooks.winrm import WinRMHook +pytestmark = pytest.mark.db_test + class TestWinRMHook: @patch("airflow.providers.microsoft.winrm.hooks.winrm.Protocol") diff --git a/tests/providers/mongo/hooks/test_mongo.py b/tests/providers/mongo/hooks/test_mongo.py index 19aa4928fc092..718a5381b7717 100644 --- a/tests/providers/mongo/hooks/test_mongo.py +++ b/tests/providers/mongo/hooks/test_mongo.py @@ -27,6 +27,8 @@ from airflow.providers.mongo.hooks.mongo import MongoHook from airflow.utils import db +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from types import ModuleType diff --git a/tests/providers/mysql/transfers/test_s3_to_mysql.py b/tests/providers/mysql/transfers/test_s3_to_mysql.py index e377fd296675d..6d98d807cb83e 100644 --- a/tests/providers/mysql/transfers/test_s3_to_mysql.py +++ b/tests/providers/mysql/transfers/test_s3_to_mysql.py @@ -26,6 +26,8 @@ from airflow.utils import db from airflow.utils.session import create_session +pytestmark = pytest.mark.db_test + class TestS3ToMySqlTransfer: def setup_method(self): diff --git a/tests/providers/openlineage/extractors/test_bash_extractor.py b/tests/providers/openlineage/extractors/test_bash_extractor.py index 0d7a786d9e1e7..201583c0ed2aa 100644 --- a/tests/providers/openlineage/extractors/test_bash_extractor.py +++ b/tests/providers/openlineage/extractors/test_bash_extractor.py @@ -30,6 +30,8 @@ from airflow.providers.openlineage.utils.utils import is_source_enabled from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + with DAG( dag_id="test_dummy_dag", description="Test dummy DAG", diff --git a/tests/providers/openlineage/extractors/test_default_extractor.py b/tests/providers/openlineage/extractors/test_default_extractor.py index 41d477aa9cfd2..3e0968d820b76 100644 --- a/tests/providers/openlineage/extractors/test_default_extractor.py +++ b/tests/providers/openlineage/extractors/test_default_extractor.py @@ -19,6 +19,7 @@ from typing import Any from unittest import mock +import pytest from attrs import Factory, define, field from openlineage.client.facet import BaseFacet, ParentRunFacet, SqlJobFacet from openlineage.client.run import Dataset @@ -32,6 +33,9 @@ from airflow.providers.openlineage.extractors.manager import ExtractorManager from airflow.providers.openlineage.extractors.python import PythonExtractor +pytestmark = pytest.mark.db_test + + INPUTS = [Dataset(namespace="database://host:port", name="inputtable")] OUTPUTS = [Dataset(namespace="database://host:port", name="inputtable")] RUN_FACETS = { diff --git a/tests/providers/openlineage/extractors/test_python_extractor.py b/tests/providers/openlineage/extractors/test_python_extractor.py index c54f33ddc5079..45cb35288f0fb 100644 --- a/tests/providers/openlineage/extractors/test_python_extractor.py +++ b/tests/providers/openlineage/extractors/test_python_extractor.py @@ -32,6 +32,8 @@ from airflow.providers.openlineage.utils.utils import is_source_enabled from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + dag = DAG( dag_id="test_dummy_dag", description="Test dummy DAG", diff --git a/tests/providers/openlineage/plugins/test_listener.py b/tests/providers/openlineage/plugins/test_listener.py index d802618967ef7..16b79891b589b 100644 --- a/tests/providers/openlineage/plugins/test_listener.py +++ b/tests/providers/openlineage/plugins/test_listener.py @@ -21,11 +21,14 @@ from unittest.mock import patch import pandas as pd +import pytest from airflow.models import DAG, TaskInstance from airflow.models.baseoperator import BaseOperator from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class TemplateOperator(BaseOperator): template_fields = ["df"] diff --git a/tests/providers/openlineage/plugins/test_openlineage_adapter.py b/tests/providers/openlineage/plugins/test_openlineage_adapter.py index cec69e0662fc8..685e88c725bc0 100644 --- a/tests/providers/openlineage/plugins/test_openlineage_adapter.py +++ b/tests/providers/openlineage/plugins/test_openlineage_adapter.py @@ -36,6 +36,8 @@ from airflow.providers.openlineage.plugins.adapter import _PRODUCER, OpenLineageAdapter from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + @patch.dict(os.environ, {"OPENLINEAGE_URL": "http://ol-api:5000", "OPENLINEAGE_API_KEY": "api-key"}) def test_create_client_from_ol_env(): diff --git a/tests/providers/openlineage/plugins/test_utils.py b/tests/providers/openlineage/plugins/test_utils.py index 2a81c0efa8dfa..19f647fcfaf48 100644 --- a/tests/providers/openlineage/plugins/test_utils.py +++ b/tests/providers/openlineage/plugins/test_utils.py @@ -23,6 +23,7 @@ from json import JSONEncoder from typing import Any +import pytest from attrs import define from openlineage.client.utils import RedactMixin from pendulum.tz.timezone import Timezone @@ -73,6 +74,7 @@ def test_url_to_https_no_url(): assert url_to_https("") is None +@pytest.mark.db_test def test_get_dagrun_start_end(): start_date = datetime.datetime(2022, 1, 1) end_date = datetime.datetime(2022, 1, 1, hour=2) diff --git a/tests/providers/openlineage/utils/test_utils.py b/tests/providers/openlineage/utils/test_utils.py index a2093652f9c0c..ce1cd3be7eb8b 100644 --- a/tests/providers/openlineage/utils/test_utils.py +++ b/tests/providers/openlineage/utils/test_utils.py @@ -17,6 +17,8 @@ # under the License. from __future__ import annotations +import pytest + from airflow.decorators import task_group from airflow.models.taskinstance import TaskInstance as TI from airflow.operators.empty import EmptyOperator @@ -27,6 +29,7 @@ DEFAULT_DATE = timezone.datetime(2016, 1, 1) +@pytest.mark.db_test def test_get_custom_facets(dag_maker): with dag_maker(dag_id="dag_test_get_custom_facets") as dag: diff --git a/tests/providers/opensearch/hooks/test_opensearch.py b/tests/providers/opensearch/hooks/test_opensearch.py index 0a39e9db3b129..570354dcdff1d 100644 --- a/tests/providers/opensearch/hooks/test_opensearch.py +++ b/tests/providers/opensearch/hooks/test_opensearch.py @@ -16,8 +16,13 @@ # under the License. from __future__ import annotations +import pytest + from airflow.providers.opensearch.hooks.opensearch import OpenSearchHook +pytestmark = pytest.mark.db_test + + MOCK_SEARCH_RETURN = {"status": "test"} diff --git a/tests/providers/opensearch/operators/test_opensearch.py b/tests/providers/opensearch/operators/test_opensearch.py index ae5fff8f785ad..23528c6f930e2 100644 --- a/tests/providers/opensearch/operators/test_opensearch.py +++ b/tests/providers/opensearch/operators/test_opensearch.py @@ -27,6 +27,9 @@ ) from airflow.utils.timezone import datetime +pytestmark = pytest.mark.db_test + + TEST_DAG_ID = "unit_tests" DEFAULT_DATE = datetime(2018, 1, 1) EXPECTED_SEARCH_RETURN = {"status": "test"} diff --git a/tests/providers/opsgenie/hooks/test_opsgenie.py b/tests/providers/opsgenie/hooks/test_opsgenie.py index 8b3a518356f12..1cdd024ced674 100644 --- a/tests/providers/opsgenie/hooks/test_opsgenie.py +++ b/tests/providers/opsgenie/hooks/test_opsgenie.py @@ -27,6 +27,8 @@ from airflow.providers.opsgenie.hooks.opsgenie import OpsgenieAlertHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestOpsgenieAlertHook: conn_id = "opsgenie_conn_id_test" diff --git a/tests/providers/oracle/operators/test_oracle.py b/tests/providers/oracle/operators/test_oracle.py index f4311362b0cf1..a8b8c2f976a84 100644 --- a/tests/providers/oracle/operators/test_oracle.py +++ b/tests/providers/oracle/operators/test_oracle.py @@ -83,6 +83,7 @@ def test_execute(self, mock_run): handler=mock.ANY, ) + @pytest.mark.db_test @mock.patch.object(OracleHook, "callproc", autospec=OracleHook.callproc) def test_push_oracle_exit_to_xcom(self, mock_callproc, request, dag_maker): # Test pulls the value previously pushed to xcom and checks if it's the same diff --git a/tests/providers/pagerduty/hooks/test_pagerduty.py b/tests/providers/pagerduty/hooks/test_pagerduty.py index a24c6363e0f71..f6df40143a072 100644 --- a/tests/providers/pagerduty/hooks/test_pagerduty.py +++ b/tests/providers/pagerduty/hooks/test_pagerduty.py @@ -26,6 +26,9 @@ from airflow.providers.pagerduty.hooks.pagerduty_events import PagerdutyEventsHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + DEFAULT_CONN_ID = "pagerduty_default" diff --git a/tests/providers/pagerduty/hooks/test_pagerduty_events.py b/tests/providers/pagerduty/hooks/test_pagerduty_events.py index 41e1920813a5c..63c60efc5d57d 100644 --- a/tests/providers/pagerduty/hooks/test_pagerduty_events.py +++ b/tests/providers/pagerduty/hooks/test_pagerduty_events.py @@ -24,6 +24,8 @@ from airflow.providers.pagerduty.hooks.pagerduty import PagerdutyEventsHook from airflow.utils import db +pytestmark = pytest.mark.db_test + DEFAULT_CONN_ID = "pagerduty_events_default" diff --git a/tests/providers/pagerduty/notifications/test_pagerduty.py b/tests/providers/pagerduty/notifications/test_pagerduty.py index 369760c3bffca..50a6753ad4ea8 100644 --- a/tests/providers/pagerduty/notifications/test_pagerduty.py +++ b/tests/providers/pagerduty/notifications/test_pagerduty.py @@ -19,6 +19,8 @@ from unittest import mock +import pytest + from airflow.operators.empty import EmptyOperator from airflow.providers.pagerduty.hooks.pagerduty_events import PagerdutyEventsHook from airflow.providers.pagerduty.notifications.pagerduty import ( @@ -26,6 +28,9 @@ send_pagerduty_notification, ) +pytestmark = pytest.mark.db_test + + PAGERDUTY_API_DEFAULT_CONN_ID = PagerdutyEventsHook.default_conn_name diff --git a/tests/providers/papermill/operators/test_papermill.py b/tests/providers/papermill/operators/test_papermill.py index 55569e68bab45..d862a2eb87e67 100644 --- a/tests/providers/papermill/operators/test_papermill.py +++ b/tests/providers/papermill/operators/test_papermill.py @@ -98,6 +98,7 @@ def test_execute(self, mock_papermill): report_mode=True, ) + @pytest.mark.db_test def test_render_template(self, create_task_instance_of_operator): """Test rendering fields.""" ti = create_task_instance_of_operator( diff --git a/tests/providers/postgres/operators/test_postgres.py b/tests/providers/postgres/operators/test_postgres.py index 03fc6fca54e99..a9ddea21d6b15 100644 --- a/tests/providers/postgres/operators/test_postgres.py +++ b/tests/providers/postgres/operators/test_postgres.py @@ -192,6 +192,7 @@ def test_postgres_operator_openlineage_explicit_schema(self): assert "schema" in lineage_on_complete.outputs[0].facets +@pytest.mark.db_test def test_parameters_are_templatized(create_task_instance_of_operator): """Test that PostgreSQL operator could template the same fields as SQLExecuteQueryOperator""" ti = create_task_instance_of_operator( diff --git a/tests/providers/redis/hooks/test_redis.py b/tests/providers/redis/hooks/test_redis.py index 119964fd3b22c..a9491d5f9d9dc 100644 --- a/tests/providers/redis/hooks/test_redis.py +++ b/tests/providers/redis/hooks/test_redis.py @@ -19,9 +19,13 @@ from unittest import mock +import pytest + from airflow.models import Connection from airflow.providers.redis.hooks.redis import RedisHook +pytestmark = pytest.mark.db_test + class TestRedisHook: def test_get_conn(self): diff --git a/tests/providers/redis/log/test_redis_task_handler.py b/tests/providers/redis/log/test_redis_task_handler.py index e27d63fdc407c..4e570cccbc4e6 100644 --- a/tests/providers/redis/log/test_redis_task_handler.py +++ b/tests/providers/redis/log/test_redis_task_handler.py @@ -30,6 +30,8 @@ from airflow.utils.timezone import datetime from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestRedisTaskHandler: @pytest.fixture diff --git a/tests/providers/salesforce/hooks/test_salesforce.py b/tests/providers/salesforce/hooks/test_salesforce.py index aa3b03a38df22..b3792c612156f 100644 --- a/tests/providers/salesforce/hooks/test_salesforce.py +++ b/tests/providers/salesforce/hooks/test_salesforce.py @@ -50,6 +50,7 @@ def test_get_conn_exists(self): assert self.salesforce_hook.conn.return_value is not None + @pytest.mark.db_test @patch("airflow.providers.salesforce.hooks.salesforce.Salesforce") def test_get_conn_password_auth(self, mock_salesforce): """ @@ -97,6 +98,7 @@ def test_get_conn_password_auth(self, mock_salesforce): privatekey=None, ) + @pytest.mark.db_test @patch("airflow.providers.salesforce.hooks.salesforce.Salesforce") def test_get_conn_direct_session_access(self, mock_salesforce): """ @@ -148,6 +150,7 @@ def test_get_conn_direct_session_access(self, mock_salesforce): privatekey=None, ) + @pytest.mark.db_test @patch("airflow.providers.salesforce.hooks.salesforce.Salesforce") def test_get_conn_jwt_auth(self, mock_salesforce): """ @@ -196,6 +199,7 @@ def test_get_conn_jwt_auth(self, mock_salesforce): privatekey=extras["private_key"], ) + @pytest.mark.db_test @patch("airflow.providers.salesforce.hooks.salesforce.Salesforce") def test_get_conn_ip_filtering_auth(self, mock_salesforce): """ @@ -240,6 +244,7 @@ def test_get_conn_ip_filtering_auth(self, mock_salesforce): privatekey=None, ) + @pytest.mark.db_test @patch("airflow.providers.salesforce.hooks.salesforce.Salesforce") def test_get_conn_default_to_none(self, mock_salesforce): """ diff --git a/tests/providers/sftp/decorators/sensors/test_sftp.py b/tests/providers/sftp/decorators/sensors/test_sftp.py index c79cd8ed3dc67..0f30e2da36d2b 100644 --- a/tests/providers/sftp/decorators/sensors/test_sftp.py +++ b/tests/providers/sftp/decorators/sensors/test_sftp.py @@ -23,6 +23,9 @@ from airflow.decorators import task from airflow.utils import timezone +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2021, 9, 9) diff --git a/tests/providers/sftp/hooks/test_sftp.py b/tests/providers/sftp/hooks/test_sftp.py index a1f6f930dbe68..847e64a138626 100644 --- a/tests/providers/sftp/hooks/test_sftp.py +++ b/tests/providers/sftp/hooks/test_sftp.py @@ -32,6 +32,8 @@ from airflow.providers.ssh.hooks.ssh import SSHHook from airflow.utils.session import provide_session +pytestmark = pytest.mark.db_test + def generate_host_key(pkey: paramiko.PKey): with StringIO() as key_fh: diff --git a/tests/providers/sftp/operators/test_sftp.py b/tests/providers/sftp/operators/test_sftp.py index 7972846d27e45..8f72a41915fbb 100644 --- a/tests/providers/sftp/operators/test_sftp.py +++ b/tests/providers/sftp/operators/test_sftp.py @@ -37,6 +37,9 @@ from airflow.utils.timezone import datetime from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2017, 1, 1) TEST_CONN_ID = "conn_id_for_testing" diff --git a/tests/providers/slack/notifications/test_slack.py b/tests/providers/slack/notifications/test_slack.py index 0e10bacd30907..4a2c1430de992 100644 --- a/tests/providers/slack/notifications/test_slack.py +++ b/tests/providers/slack/notifications/test_slack.py @@ -24,6 +24,8 @@ from airflow.operators.empty import EmptyOperator from airflow.providers.slack.notifications.slack import SlackNotifier, send_slack_notification +pytestmark = pytest.mark.db_test + DEFAULT_HOOKS_PARAMETERS = {"base_url": None, "timeout": None, "proxy": None, "retry_handlers": None} diff --git a/tests/providers/slack/notifications/test_slack_webhook.py b/tests/providers/slack/notifications/test_slack_webhook.py index 12f27c4b23b33..f1a2674f0860f 100644 --- a/tests/providers/slack/notifications/test_slack_webhook.py +++ b/tests/providers/slack/notifications/test_slack_webhook.py @@ -27,6 +27,8 @@ send_slack_webhook_notification, ) +pytestmark = pytest.mark.db_test + DEFAULT_HOOKS_PARAMETERS = {"timeout": None, "proxy": None, "retry_handlers": None} diff --git a/tests/providers/slack/transfers/test_sql_to_slack.py b/tests/providers/slack/transfers/test_sql_to_slack.py index c2d698719f736..cb33fff5162ec 100644 --- a/tests/providers/slack/transfers/test_sql_to_slack.py +++ b/tests/providers/slack/transfers/test_sql_to_slack.py @@ -106,6 +106,7 @@ def test_get_query_results(self, mock_op_get_hook, sql, parameters): assert df is test_df +@pytest.mark.db_test class TestSqlToSlackOperator: def setup_method(self): self.example_dag = DAG(TEST_DAG_ID, start_date=DEFAULT_DATE) diff --git a/tests/providers/smtp/hooks/test_smtp.py b/tests/providers/smtp/hooks/test_smtp.py index 1126234aaacab..505fc303051ef 100644 --- a/tests/providers/smtp/hooks/test_smtp.py +++ b/tests/providers/smtp/hooks/test_smtp.py @@ -32,6 +32,9 @@ from airflow.utils.session import create_session from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + smtplib_string = "airflow.providers.smtp.hooks.smtp.smtplib" TEST_EMAILS = ["test1@example.com", "test2@example.com"] diff --git a/tests/providers/smtp/notifications/test_smtp.py b/tests/providers/smtp/notifications/test_smtp.py index 11578022d8208..36c1ac780decd 100644 --- a/tests/providers/smtp/notifications/test_smtp.py +++ b/tests/providers/smtp/notifications/test_smtp.py @@ -19,6 +19,8 @@ from unittest import mock +import pytest + from airflow.operators.empty import EmptyOperator from airflow.providers.smtp.hooks.smtp import SmtpHook from airflow.providers.smtp.notifications.smtp import ( @@ -26,6 +28,8 @@ send_smtp_notification, ) +pytestmark = pytest.mark.db_test + SMTP_API_DEFAULT_CONN_ID = SmtpHook.default_conn_name diff --git a/tests/providers/snowflake/operators/test_snowflake.py b/tests/providers/snowflake/operators/test_snowflake.py index ad294c89a83f2..07df5fb147a41 100644 --- a/tests/providers/snowflake/operators/test_snowflake.py +++ b/tests/providers/snowflake/operators/test_snowflake.py @@ -54,6 +54,7 @@ SINGLE_STMT = "select i from user_test order by i;" +@pytest.mark.db_test class TestSnowflakeOperator: def setup_method(self): args = {"owner": "airflow", "start_date": DEFAULT_DATE} diff --git a/tests/providers/sqlite/hooks/test_sqlite.py b/tests/providers/sqlite/hooks/test_sqlite.py index e4d4c36b1996a..9023882201529 100644 --- a/tests/providers/sqlite/hooks/test_sqlite.py +++ b/tests/providers/sqlite/hooks/test_sqlite.py @@ -26,6 +26,8 @@ from airflow.models import Connection from airflow.providers.sqlite.hooks.sqlite import SqliteHook +pytestmark = pytest.mark.db_test + class TestSqliteHookConn: def setup_method(self): @@ -137,6 +139,7 @@ def test_generate_insert_sql_replace_true(self): assert sql == expected_sql + @pytest.mark.db_test def test_sqlalchemy_engine(self): """Test that the sqlalchemy engine is initialized""" conn_id = "sqlite_default" diff --git a/tests/providers/ssh/hooks/test_ssh.py b/tests/providers/ssh/hooks/test_ssh.py index d2af9573e6b80..2adbf0cce10ed 100644 --- a/tests/providers/ssh/hooks/test_ssh.py +++ b/tests/providers/ssh/hooks/test_ssh.py @@ -34,6 +34,9 @@ from airflow.utils import db from airflow.utils.session import create_session +pytestmark = pytest.mark.db_test + + HELLO_SERVER_CMD = """ import socket, sys listener = socket.socket() diff --git a/tests/providers/ssh/operators/test_ssh.py b/tests/providers/ssh/operators/test_ssh.py index f4a8e14292ac1..1467b73e43baf 100644 --- a/tests/providers/ssh/operators/test_ssh.py +++ b/tests/providers/ssh/operators/test_ssh.py @@ -31,6 +31,9 @@ from airflow.utils.types import NOTSET from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + + TEST_DAG_ID = "unit_tests_ssh_test_op" TEST_CONN_ID = "conn_id_for_testing" DEFAULT_TIMEOUT = 10 diff --git a/tests/providers/tableau/hooks/test_tableau.py b/tests/providers/tableau/hooks/test_tableau.py index b463fce31017c..a6cf7ca3c25d4 100644 --- a/tests/providers/tableau/hooks/test_tableau.py +++ b/tests/providers/tableau/hooks/test_tableau.py @@ -24,6 +24,8 @@ from airflow.providers.tableau.hooks.tableau import TableauHook, TableauJobFinishCode from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestTableauHook: """ diff --git a/tests/providers/tabular/hooks/test_tabular.py b/tests/providers/tabular/hooks/test_tabular.py index eb9de575ada90..edebc6eaf2a19 100644 --- a/tests/providers/tabular/hooks/test_tabular.py +++ b/tests/providers/tabular/hooks/test_tabular.py @@ -17,10 +17,13 @@ # under the License. from __future__ import annotations +import pytest import requests_mock from airflow.providers.tabular.hooks.tabular import TabularHook +pytestmark = pytest.mark.db_test + def test_tabular_hook(): access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSU" diff --git a/tests/providers/telegram/hooks/test_telegram.py b/tests/providers/telegram/hooks/test_telegram.py index 6aa83df5dac0e..d2bb17e974745 100644 --- a/tests/providers/telegram/hooks/test_telegram.py +++ b/tests/providers/telegram/hooks/test_telegram.py @@ -27,6 +27,9 @@ from airflow.providers.telegram.hooks.telegram import TelegramHook from airflow.utils import db +pytestmark = pytest.mark.db_test + + TELEGRAM_TOKEN = "dummy token" diff --git a/tests/providers/telegram/operators/test_telegram.py b/tests/providers/telegram/operators/test_telegram.py index f375ca3ad4557..25f1302f2660e 100644 --- a/tests/providers/telegram/operators/test_telegram.py +++ b/tests/providers/telegram/operators/test_telegram.py @@ -27,6 +27,8 @@ from airflow.providers.telegram.operators.telegram import TelegramOperator from airflow.utils import db +pytestmark = pytest.mark.db_test + TELEGRAM_TOKEN = "xxx:xxx" diff --git a/tests/providers/zendesk/hooks/test_zendesk.py b/tests/providers/zendesk/hooks/test_zendesk.py index a5a7f5844f1ac..15d87a846c2a0 100644 --- a/tests/providers/zendesk/hooks/test_zendesk.py +++ b/tests/providers/zendesk/hooks/test_zendesk.py @@ -26,6 +26,8 @@ from airflow.providers.zendesk.hooks.zendesk import ZendeskHook from airflow.utils import db +pytestmark = pytest.mark.db_test + class TestZendeskHook: conn_id = "zendesk_conn_id_test" diff --git a/tests/security/test_kerberos.py b/tests/security/test_kerberos.py index 50da424c3d7b9..4989aeed8d7f0 100644 --- a/tests/security/test_kerberos.py +++ b/tests/security/test_kerberos.py @@ -27,6 +27,8 @@ from airflow.security.kerberos import get_kerberos_principle, renew_from_kt from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestKerberos: @pytest.mark.parametrize( diff --git a/tests/sensors/test_base.py b/tests/sensors/test_base.py index 02e1f2ed5ae02..9d12c6237f766 100644 --- a/tests/sensors/test_base.py +++ b/tests/sensors/test_base.py @@ -60,6 +60,8 @@ from airflow.utils.timezone import datetime from tests.test_utils import db +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from airflow.utils.context import Context diff --git a/tests/sensors/test_external_task_sensor.py b/tests/sensors/test_external_task_sensor.py index 376aa27bb16f0..215ce47d56625 100644 --- a/tests/sensors/test_external_task_sensor.py +++ b/tests/sensors/test_external_task_sensor.py @@ -56,6 +56,9 @@ from tests.test_utils.db import clear_db_runs from tests.test_utils.mock_operators import MockOperator +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2015, 1, 1) TEST_DAG_ID = "unit_test_dag" TEST_TASK_ID = "time_sensor_check" diff --git a/tests/sensors/test_filesystem.py b/tests/sensors/test_filesystem.py index 8c9750563c30e..9a92ce79be470 100644 --- a/tests/sensors/test_filesystem.py +++ b/tests/sensors/test_filesystem.py @@ -28,6 +28,9 @@ from airflow.sensors.filesystem import FileSensor from airflow.utils.timezone import datetime +pytestmark = pytest.mark.db_test + + TEST_DAG_ID = "unit_tests_file_sensor" DEFAULT_DATE = datetime(2015, 1, 1) diff --git a/tests/sensors/test_python.py b/tests/sensors/test_python.py index ec515d8dee0c7..a971b8a1466af 100644 --- a/tests/sensors/test_python.py +++ b/tests/sensors/test_python.py @@ -27,6 +27,8 @@ from airflow.sensors.python import PythonSensor from tests.operators.test_python import BasePythonTest +pytestmark = pytest.mark.db_test + class TestPythonSensor(BasePythonTest): opcls = PythonSensor diff --git a/tests/sensors/test_time_delta.py b/tests/sensors/test_time_delta.py index d1e5f3c0ca625..b19af4a8a8f2f 100644 --- a/tests/sensors/test_time_delta.py +++ b/tests/sensors/test_time_delta.py @@ -19,11 +19,16 @@ from datetime import timedelta +import pytest + from airflow.models import DagBag from airflow.models.dag import DAG from airflow.sensors.time_delta import TimeDeltaSensor from airflow.utils.timezone import datetime +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2015, 1, 1) DEV_NULL = "/dev/null" TEST_DAG_ID = "unit_tests" diff --git a/tests/sensors/test_timeout_sensor.py b/tests/sensors/test_timeout_sensor.py index 7b76e3d8489ad..315658a607ae1 100644 --- a/tests/sensors/test_timeout_sensor.py +++ b/tests/sensors/test_timeout_sensor.py @@ -29,6 +29,8 @@ from airflow.utils import timezone from airflow.utils.timezone import datetime +pytestmark = pytest.mark.db_test + if TYPE_CHECKING: from airflow.utils.context import Context diff --git a/tests/sensors/test_weekday_sensor.py b/tests/sensors/test_weekday_sensor.py index d5aa12f5a8c25..15df6ac3b0748 100644 --- a/tests/sensors/test_weekday_sensor.py +++ b/tests/sensors/test_weekday_sensor.py @@ -27,6 +27,9 @@ from airflow.utils.weekday import WeekDay from tests.test_utils import db +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2018, 12, 10) WEEKDAY_DATE = datetime(2018, 12, 20) WEEKEND_DATE = datetime(2018, 12, 22) diff --git a/tests/serialization/test_dag_serialization.py b/tests/serialization/test_dag_serialization.py index d2a762efa788e..3244f3b7be540 100644 --- a/tests/serialization/test_dag_serialization.py +++ b/tests/serialization/test_dag_serialization.py @@ -381,6 +381,7 @@ def setup_method(self): def teardown_method(self): BaseHook.get_connection = self.backup_base_hook_get_connection + @pytest.mark.db_test def test_serialization(self): """Serialization and deserialization should work for every DAG and Operator.""" dags = collect_dags() @@ -959,6 +960,7 @@ def test_task_params_roundtrip(self, val, expected_val): deserialized_simple_task = deserialized_dag.task_dict["simple_task"] assert expected_val == deserialized_simple_task.params.dump() + @pytest.mark.db_test @pytest.mark.parametrize( ("bash_command", "serialized_links", "links"), [ @@ -1040,6 +1042,7 @@ def test_extra_serialized_field_and_operator_links( link = simple_task.get_extra_links(ti, GoogleLink.name) assert "https://www.google.com" == link + @pytest.mark.db_test def test_extra_operator_links_logs_error_for_non_registered_extra_links(self, caplog): """ Assert OperatorLinks not registered via Plugins and if it is not an inbuilt Operator Link, @@ -1411,6 +1414,7 @@ def test_setup_teardown_tasks(self): se_second_group.children["group1.group2.teardown2"], is_teardown=True ) + @pytest.mark.db_test def test_teardown_task_on_failure_fail_dagrun_serialization(self, dag_maker): with dag_maker() as dag: @@ -1430,6 +1434,7 @@ def mytask(): assert task.is_teardown is True assert task.on_failure_fail_dagrun is True + @pytest.mark.db_test def test_teardown_mapped_serialization(self, dag_maker): with dag_maker() as dag: @@ -1453,6 +1458,7 @@ def mytask(val=None): assert task.partial_kwargs["is_teardown"] is True assert task.partial_kwargs["on_failure_fail_dagrun"] is True + @pytest.mark.db_test def test_deps_sorted(self): """ Tests serialize_operator, make sure the deps is in order @@ -1510,6 +1516,7 @@ def test_error_on_unregistered_ti_dep_deserialization(self): with pytest.raises(SerializationError): SerializedBaseOperator.deserialize_operator(serialize_op) + @pytest.mark.db_test def test_serialize_and_deserialize_custom_ti_deps(self): from test_plugin import CustomTestTriggerRule @@ -1555,6 +1562,7 @@ def test_serialize_mapped_outlets(self): assert round_tripped.inlets == [] assert round_tripped.outlets == [] + @pytest.mark.db_test def test_derived_dag_deps_sensor(self): """ Tests DAG dependency detection for sensors, including derived classes @@ -1586,6 +1594,7 @@ class DerivedSensor(ExternalTaskSensor): } ] + @pytest.mark.db_test @conf_vars( { ( @@ -1631,6 +1640,7 @@ def test_custom_dep_detector(self): key=lambda x: tuple(x.values()), ) + @pytest.mark.db_test def test_dag_deps_datasets(self): """ Check that dag_dependencies node is populated correctly for a DAG with datasets. @@ -1817,6 +1827,7 @@ def test_edge_info_serialization(self): assert serialized_dag.edge_info == dag.edge_info + @pytest.mark.db_test @pytest.mark.parametrize("mode", ["poke", "reschedule"]) def test_serialize_sensor(self, mode): from airflow.sensors.base import BaseSensorOperator @@ -2289,6 +2300,7 @@ def test_operator_expand_deserialized_unmap(): assert deserialize(serialize(mapped)).unmap(None) == deserialize(serialize(normal)) +@pytest.mark.db_test def test_sensor_expand_deserialized_unmap(): """Unmap a deserialized mapped sensor should be similar to deserializing a non-mapped sensor""" normal = BashSensor(task_id="a", bash_command=[1, 2], mode="reschedule") @@ -2555,6 +2567,7 @@ def tg(a: str) -> None: assert serde_tg._expand_input == DictOfListsExpandInput({"a": [".", ".."]}) +@pytest.mark.db_test def test_mapped_task_with_operator_extra_links_property(): class _DummyOperator(BaseOperator): def __init__(self, inputs, **kwargs): diff --git a/tests/serialization/test_pydantic_models.py b/tests/serialization/test_pydantic_models.py index 031f08d852e6a..b64d0b5aa8abd 100644 --- a/tests/serialization/test_pydantic_models.py +++ b/tests/serialization/test_pydantic_models.py @@ -39,6 +39,8 @@ from airflow.utils.types import DagRunType from tests.models import DEFAULT_DATE +pytestmark = pytest.mark.db_test + @pytest.mark.skipif(not _ENABLE_AIP_44, reason="AIP-44 is disabled") def test_serializing_pydantic_task_instance(session, create_task_instance): diff --git a/tests/serialization/test_serialized_objects.py b/tests/serialization/test_serialized_objects.py index e1ff8bace4a85..e05f69114c6da 100644 --- a/tests/serialization/test_serialized_objects.py +++ b/tests/serialization/test_serialized_objects.py @@ -278,6 +278,7 @@ def test_serialize_deserialize_pydantic(input, pydantic_class, encoded_type, cmp BaseSerialization.serialize(obj, use_pydantic_models=True) # does not raise +@pytest.mark.db_test def test_serialized_mapped_operator_unmap(dag_maker): from airflow.serialization.serialized_objects import SerializedDAG from tests.test_utils.mock_operators import MockOperator diff --git a/tests/task/task_runner/test_base_task_runner.py b/tests/task/task_runner/test_base_task_runner.py index 90edf7e32086d..7bcf0a91917f5 100644 --- a/tests/task/task_runner/test_base_task_runner.py +++ b/tests/task/task_runner/test_base_task_runner.py @@ -26,6 +26,8 @@ from airflow.models.baseoperator import BaseOperator from airflow.task.task_runner.base_task_runner import BaseTaskRunner +pytestmark = pytest.mark.db_test + @pytest.mark.parametrize(["impersonation"], (("nobody",), (None,))) @mock.patch("subprocess.check_call") diff --git a/tests/task/task_runner/test_standard_task_runner.py b/tests/task/task_runner/test_standard_task_runner.py index 6f1f60d77cf0a..9f3968220b35b 100644 --- a/tests/task/task_runner/test_standard_task_runner.py +++ b/tests/task/task_runner/test_standard_task_runner.py @@ -132,6 +132,7 @@ def test_start_and_terminate(self, mock_init): assert task_runner.return_code() is not None + @pytest.mark.db_test def test_notifies_about_start_and_stop(self, tmp_path): path_listener_writer = tmp_path / "test_notifies_about_start_and_stop" @@ -172,6 +173,7 @@ def test_notifies_about_start_and_stop(self, tmp_path): assert f.readline() == "on_task_instance_success\n" assert f.readline() == "before_stopping\n" + @pytest.mark.db_test def test_notifies_about_fail(self, tmp_path): path_listener_writer = tmp_path / "test_notifies_about_fail" @@ -212,6 +214,7 @@ def test_notifies_about_fail(self, tmp_path): assert f.readline() == "on_task_instance_failed\n" assert f.readline() == "before_stopping\n" + @pytest.mark.db_test def test_ol_does_not_block_xcoms(self, tmp_path): """ Test that ensures that pushing and pulling xcoms both in listener and task does not collide @@ -337,6 +340,7 @@ def test_early_reap_exit(self, mock_init, caplog): assert task_runner.return_code() == -9 assert "running out of memory" in caplog.text + @pytest.mark.db_test def test_on_kill(self): """ Test that ensures that clearing in the UI SIGTERMS @@ -395,6 +399,7 @@ def test_on_kill(self): for process in processes: assert not psutil.pid_exists(process.pid), f"{process} is still alive" + @pytest.mark.db_test def test_parsing_context(self): context_file = Path("/tmp/airflow_parsing_context") context_file.unlink(missing_ok=True) diff --git a/tests/task/task_runner/test_task_runner.py b/tests/task/task_runner/test_task_runner.py index 1c9928f6b3a51..2d5794aff7906 100644 --- a/tests/task/task_runner/test_task_runner.py +++ b/tests/task/task_runner/test_task_runner.py @@ -24,6 +24,9 @@ from airflow.task.task_runner import CORE_TASK_RUNNERS, get_task_runner from airflow.utils.module_loading import import_string +pytestmark = pytest.mark.db_test + + custom_task_runner = mock.MagicMock() diff --git a/tests/ti_deps/deps/test_dag_ti_slots_available_dep.py b/tests/ti_deps/deps/test_dag_ti_slots_available_dep.py index 61fc43c9666e2..deabfa1d0b9e9 100644 --- a/tests/ti_deps/deps/test_dag_ti_slots_available_dep.py +++ b/tests/ti_deps/deps/test_dag_ti_slots_available_dep.py @@ -19,9 +19,13 @@ from unittest.mock import Mock +import pytest + from airflow.models import TaskInstance from airflow.ti_deps.deps.dag_ti_slots_available_dep import DagTISlotsAvailableDep +pytestmark = pytest.mark.db_test + class TestDagTISlotsAvailableDep: def test_concurrency_reached(self): diff --git a/tests/ti_deps/deps/test_dag_unpaused_dep.py b/tests/ti_deps/deps/test_dag_unpaused_dep.py index 10feee1b22e07..3a6b324c3d481 100644 --- a/tests/ti_deps/deps/test_dag_unpaused_dep.py +++ b/tests/ti_deps/deps/test_dag_unpaused_dep.py @@ -19,9 +19,13 @@ from unittest.mock import Mock +import pytest + from airflow.models import TaskInstance from airflow.ti_deps.deps.dag_unpaused_dep import DagUnpausedDep +pytestmark = pytest.mark.db_test + class TestDagUnpausedDep: def test_concurrency_reached(self): diff --git a/tests/ti_deps/deps/test_dagrun_exists_dep.py b/tests/ti_deps/deps/test_dagrun_exists_dep.py index 9d19e8f02042b..33b039ada57de 100644 --- a/tests/ti_deps/deps/test_dagrun_exists_dep.py +++ b/tests/ti_deps/deps/test_dagrun_exists_dep.py @@ -19,11 +19,15 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models.dag import DAG from airflow.models.dagrun import DagRun from airflow.ti_deps.deps.dagrun_exists_dep import DagrunRunningDep from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class TestDagrunRunningDep: @patch("airflow.models.DagRun.find", return_value=()) diff --git a/tests/ti_deps/deps/test_dagrun_id_dep.py b/tests/ti_deps/deps/test_dagrun_id_dep.py index 3e157212fa930..e701a910c5b88 100644 --- a/tests/ti_deps/deps/test_dagrun_id_dep.py +++ b/tests/ti_deps/deps/test_dagrun_id_dep.py @@ -19,10 +19,14 @@ from unittest.mock import Mock +import pytest + from airflow.models.dagrun import DagRun from airflow.ti_deps.deps.dagrun_backfill_dep import DagRunNotBackfillDep from airflow.utils.types import DagRunType +pytestmark = pytest.mark.db_test + class TestDagrunRunningDep: def test_run_id_is_backfill(self): diff --git a/tests/ti_deps/deps/test_not_in_retry_period_dep.py b/tests/ti_deps/deps/test_not_in_retry_period_dep.py index 2abf42273ad65..d2b1555a3a517 100644 --- a/tests/ti_deps/deps/test_not_in_retry_period_dep.py +++ b/tests/ti_deps/deps/test_not_in_retry_period_dep.py @@ -20,6 +20,7 @@ from datetime import timedelta from unittest.mock import Mock +import pytest import time_machine from airflow.models import TaskInstance @@ -27,6 +28,8 @@ from airflow.utils.state import State from airflow.utils.timezone import datetime +pytestmark = pytest.mark.db_test + class TestNotInRetryPeriodDep: def _get_task_instance(self, state, end_date=None, retry_delay=timedelta(minutes=15)): diff --git a/tests/ti_deps/deps/test_not_previously_skipped_dep.py b/tests/ti_deps/deps/test_not_previously_skipped_dep.py index 8009582ae6784..0a8a0e79c9a69 100644 --- a/tests/ti_deps/deps/test_not_previously_skipped_dep.py +++ b/tests/ti_deps/deps/test_not_previously_skipped_dep.py @@ -28,6 +28,8 @@ from airflow.utils.state import State from airflow.utils.types import DagRunType +pytestmark = pytest.mark.db_test + @pytest.fixture(autouse=True, scope="function") def clean_db(session): diff --git a/tests/ti_deps/deps/test_pool_slots_available_dep.py b/tests/ti_deps/deps/test_pool_slots_available_dep.py index 08abba29e4171..b50d025389db1 100644 --- a/tests/ti_deps/deps/test_pool_slots_available_dep.py +++ b/tests/ti_deps/deps/test_pool_slots_available_dep.py @@ -19,6 +19,8 @@ from unittest.mock import Mock, patch +import pytest + from airflow.models import Pool from airflow.ti_deps.dependencies_states import EXECUTION_STATES from airflow.ti_deps.deps.pool_slots_available_dep import PoolSlotsAvailableDep @@ -26,6 +28,8 @@ from airflow.utils.state import TaskInstanceState from tests.test_utils import db +pytestmark = pytest.mark.db_test + class TestPoolSlotsAvailableDep: def setup_method(self): diff --git a/tests/ti_deps/deps/test_prev_dagrun_dep.py b/tests/ti_deps/deps/test_prev_dagrun_dep.py index a6ef3927cae3e..b59bdbeb7a824 100644 --- a/tests/ti_deps/deps/test_prev_dagrun_dep.py +++ b/tests/ti_deps/deps/test_prev_dagrun_dep.py @@ -30,6 +30,8 @@ from airflow.utils.types import DagRunType from tests.test_utils.db import clear_db_runs +pytestmark = pytest.mark.db_test + class TestPrevDagrunDep: def teardown_method(self): diff --git a/tests/ti_deps/deps/test_ready_to_reschedule_dep.py b/tests/ti_deps/deps/test_ready_to_reschedule_dep.py index 1d56da8ff3d43..421741a03694b 100644 --- a/tests/ti_deps/deps/test_ready_to_reschedule_dep.py +++ b/tests/ti_deps/deps/test_ready_to_reschedule_dep.py @@ -32,6 +32,9 @@ from airflow.utils.state import State from tests.test_utils import db +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = timezone.datetime(2016, 1, 1) diff --git a/tests/ti_deps/deps/test_runnable_exec_date_dep.py b/tests/ti_deps/deps/test_runnable_exec_date_dep.py index 210a8ddbb373b..3e61d8d471238 100644 --- a/tests/ti_deps/deps/test_runnable_exec_date_dep.py +++ b/tests/ti_deps/deps/test_runnable_exec_date_dep.py @@ -28,6 +28,8 @@ from airflow.utils.timezone import datetime from airflow.utils.types import DagRunType +pytestmark = pytest.mark.db_test + @pytest.fixture(autouse=True, scope="function") def clean_db(session): diff --git a/tests/ti_deps/deps/test_task_concurrency.py b/tests/ti_deps/deps/test_task_concurrency.py index 59698565a0f76..34373e76c92d6 100644 --- a/tests/ti_deps/deps/test_task_concurrency.py +++ b/tests/ti_deps/deps/test_task_concurrency.py @@ -27,6 +27,8 @@ from airflow.ti_deps.dep_context import DepContext from airflow.ti_deps.deps.task_concurrency_dep import TaskConcurrencyDep +pytestmark = pytest.mark.db_test + class TestTaskConcurrencyDep: def _get_task(self, **kwargs): diff --git a/tests/ti_deps/deps/test_task_not_running_dep.py b/tests/ti_deps/deps/test_task_not_running_dep.py index 62a1a1f59d8fd..84fe6377597c9 100644 --- a/tests/ti_deps/deps/test_task_not_running_dep.py +++ b/tests/ti_deps/deps/test_task_not_running_dep.py @@ -20,9 +20,13 @@ from datetime import datetime from unittest.mock import Mock +import pytest + from airflow.ti_deps.deps.task_not_running_dep import TaskNotRunningDep from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class TestTaskNotRunningDep: def test_not_running_state(self): diff --git a/tests/ti_deps/deps/test_trigger_rule_dep.py b/tests/ti_deps/deps/test_trigger_rule_dep.py index f0c102f12e12f..00cbcd449af3e 100644 --- a/tests/ti_deps/deps/test_trigger_rule_dep.py +++ b/tests/ti_deps/deps/test_trigger_rule_dep.py @@ -33,6 +33,9 @@ from airflow.utils.state import DagRunState, TaskInstanceState from airflow.utils.trigger_rule import TriggerRule +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from airflow.models.dagrun import DagRun diff --git a/tests/ti_deps/deps/test_valid_state_dep.py b/tests/ti_deps/deps/test_valid_state_dep.py index 9fb862341729f..15e6c3f5aa6c6 100644 --- a/tests/ti_deps/deps/test_valid_state_dep.py +++ b/tests/ti_deps/deps/test_valid_state_dep.py @@ -26,6 +26,8 @@ from airflow.ti_deps.deps.valid_state_dep import ValidStateDep from airflow.utils.state import State +pytestmark = pytest.mark.db_test + class TestValidStateDep: def test_valid_state(self): diff --git a/tests/triggers/test_external_task.py b/tests/triggers/test_external_task.py index 8f25e20846b24..f8295b331cc51 100644 --- a/tests/triggers/test_external_task.py +++ b/tests/triggers/test_external_task.py @@ -36,6 +36,7 @@ class TestTaskStateTrigger: RUN_ID = "external_task_run_id" STATES = ["success", "fail"] + @pytest.mark.db_test @pytest.mark.asyncio async def test_task_state_trigger(self, session): """ @@ -113,6 +114,7 @@ class TestDagStateTrigger: RUN_ID = "external_task_run_id" STATES = ["success", "fail"] + @pytest.mark.db_test @pytest.mark.asyncio async def test_dag_state_trigger(self, session): """ diff --git a/tests/utils/log/test_colored_log.py b/tests/utils/log/test_colored_log.py index e91b2fc321974..e90029361f67c 100644 --- a/tests/utils/log/test_colored_log.py +++ b/tests/utils/log/test_colored_log.py @@ -20,8 +20,12 @@ import logging from unittest.mock import patch +import pytest + from airflow.utils.log.colored_log import CustomTTYColoredFormatter +pytestmark = pytest.mark.db_test + @patch("airflow.utils.log.timezone_aware.TimezoneAware.formatTime") def test_format_time_uses_tz_aware(mock_fmt): diff --git a/tests/utils/log/test_log_reader.py b/tests/utils/log/test_log_reader.py index 81dffc8afc30d..0dcb503c19dea 100644 --- a/tests/utils/log/test_log_reader.py +++ b/tests/utils/log/test_log_reader.py @@ -41,6 +41,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_dags, clear_db_runs +pytestmark = pytest.mark.db_test + + if TYPE_CHECKING: from airflow.models import DagRun diff --git a/tests/utils/test_cli_util.py b/tests/utils/test_cli_util.py index 99ee65fc5e47d..5c0edcd2a2953 100644 --- a/tests/utils/test_cli_util.py +++ b/tests/utils/test_cli_util.py @@ -79,6 +79,7 @@ def test_success_function(self): def test_process_subdir_path_with_placeholder(self): assert os.path.join(settings.DAGS_FOLDER, "abc") == cli.process_subdir("DAGS_FOLDER/abc") + @pytest.mark.db_test def test_get_dags(self): dags = cli.get_dags(None, "example_subdag_operator") assert len(dags) == 1 @@ -89,6 +90,7 @@ def test_get_dags(self): with pytest.raises(AirflowException): cli.get_dags(None, "foobar", True) + @pytest.mark.db_test @pytest.mark.parametrize( ["given_command", "expected_masked_command"], [ diff --git a/tests/utils/test_db.py b/tests/utils/test_db.py index 3ec3a63f4cc31..f44f4e2474f9c 100644 --- a/tests/utils/test_db.py +++ b/tests/utils/test_db.py @@ -53,6 +53,8 @@ ) from airflow.utils.session import NEW_SESSION +pytestmark = pytest.mark.db_test + class TestDb: def test_database_schema_and_sqlalchemy_model_are_in_sync(self): diff --git a/tests/utils/test_db_cleanup.py b/tests/utils/test_db_cleanup.py index 39dc314cc702f..55707bd315dbd 100644 --- a/tests/utils/test_db_cleanup.py +++ b/tests/utils/test_db_cleanup.py @@ -50,6 +50,8 @@ from airflow.utils.session import create_session from tests.test_utils.db import clear_db_dags, clear_db_datasets, clear_db_runs, drop_tables_with_prefix +pytestmark = pytest.mark.db_test + @pytest.fixture(autouse=True) def clean_database(): diff --git a/tests/utils/test_dot_renderer.py b/tests/utils/test_dot_renderer.py index e4f931abf202e..4497b3955afe3 100644 --- a/tests/utils/test_dot_renderer.py +++ b/tests/utils/test_dot_renderer.py @@ -20,6 +20,8 @@ from unittest import mock +import pytest + from airflow.models.dag import DAG from airflow.operators.bash import BashOperator from airflow.operators.empty import EmptyOperator @@ -32,6 +34,8 @@ START_DATE = timezone.utcnow() +pytestmark = pytest.mark.db_test + class TestDotRenderer: def setup_class(self): diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py index ba4f9604d7c9e..625aa608f74c6 100644 --- a/tests/utils/test_helpers.py +++ b/tests/utils/test_helpers.py @@ -53,6 +53,7 @@ def clear_db(): class TestHelpers: + @pytest.mark.db_test @pytest.mark.usefixtures("clear_db") def test_render_log_filename(self, create_task_instance): try_number = 1 @@ -159,6 +160,7 @@ def test_merge_dicts_recursive_right_only(self): merged = merge_dicts(dict1, dict2) assert merged == {"a": 1, "r": {"b": 0, "c": 3}} + @pytest.mark.db_test @conf_vars( { ("webserver", "dag_default_view"): "graph", diff --git a/tests/utils/test_log_handlers.py b/tests/utils/test_log_handlers.py index b6449aa60e092..d2c8aa90ec917 100644 --- a/tests/utils/test_log_handlers.py +++ b/tests/utils/test_log_handlers.py @@ -51,6 +51,8 @@ from airflow.utils.types import DagRunType from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + DEFAULT_DATE = datetime(2016, 1, 1) TASK_LOGGER = "airflow.task" FILE_TASK_HANDLER = "task" diff --git a/tests/utils/test_process_utils.py b/tests/utils/test_process_utils.py index 826355329871c..ac591248ae49b 100644 --- a/tests/utils/test_process_utils.py +++ b/tests/utils/test_process_utils.py @@ -99,6 +99,7 @@ def test_reap_process_group(self): pass +@pytest.mark.db_test class TestExecuteInSubProcess: def test_should_print_all_messages1(self, caplog): execute_in_subprocess(["bash", "-c", "echo CAT; echo KITTY;"]) @@ -135,6 +136,7 @@ def my_sleep_subprocess_with_signals(): sleep(100) +@pytest.mark.db_test class TestKillChildProcessesByPids: def test_should_kill_process(self): before_num_process = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().count("\n") diff --git a/tests/utils/test_retries.py b/tests/utils/test_retries.py index d1237dd86fb5e..122ea81ec6d93 100644 --- a/tests/utils/test_retries.py +++ b/tests/utils/test_retries.py @@ -44,6 +44,7 @@ def test_function(session): assert mock_obj.call_count == 2 + @pytest.mark.db_test def test_retry_db_transaction_with_default_retries(self, caplog): """Test that by default 3 retries will be carried out""" mock_obj = mock.MagicMock() diff --git a/tests/utils/test_session.py b/tests/utils/test_session.py index e306c6599f287..70e2f03c2aad9 100644 --- a/tests/utils/test_session.py +++ b/tests/utils/test_session.py @@ -21,6 +21,8 @@ from airflow.utils.session import provide_session +pytestmark = pytest.mark.db_test + class TestSession: def dummy_session(self, session=None): diff --git a/tests/utils/test_sqlalchemy.py b/tests/utils/test_sqlalchemy.py index 111068bf820cb..e01d0904ad0fb 100644 --- a/tests/utils/test_sqlalchemy.py +++ b/tests/utils/test_sqlalchemy.py @@ -44,6 +44,9 @@ from airflow.utils.state import State from airflow.utils.timezone import utcnow +pytestmark = pytest.mark.db_test + + TEST_POD = k8s.V1Pod(spec=k8s.V1PodSpec(containers=[k8s.V1Container(name="base")])) diff --git a/tests/utils/test_state.py b/tests/utils/test_state.py index 4882fae76f9d9..a9f8a04f6ccb9 100644 --- a/tests/utils/test_state.py +++ b/tests/utils/test_state.py @@ -16,6 +16,8 @@ # under the License. from __future__ import annotations +import pytest + from airflow.models.dag import DAG from airflow.models.dagrun import DagRun from airflow.utils.session import create_session @@ -23,6 +25,8 @@ from airflow.utils.types import DagRunType from tests.models import DEFAULT_DATE +pytestmark = pytest.mark.db_test + def test_dagrun_state_enum_escape(): """ diff --git a/tests/utils/test_task_handler_with_custom_formatter.py b/tests/utils/test_task_handler_with_custom_formatter.py index 7439fc3059c15..83a0125d736cc 100644 --- a/tests/utils/test_task_handler_with_custom_formatter.py +++ b/tests/utils/test_task_handler_with_custom_formatter.py @@ -32,6 +32,9 @@ from tests.test_utils.config import conf_vars from tests.test_utils.db import clear_db_runs +pytestmark = pytest.mark.db_test + + DEFAULT_DATE = datetime(2019, 1, 1) TASK_HANDLER = "task" TASK_HANDLER_CLASS = "airflow.utils.log.task_handler_with_custom_formatter.TaskHandlerWithCustomFormatter" diff --git a/tests/utils/test_types.py b/tests/utils/test_types.py index 4d9ffb27e2cc8..1cc82c6ad8862 100644 --- a/tests/utils/test_types.py +++ b/tests/utils/test_types.py @@ -16,6 +16,8 @@ # under the License. from __future__ import annotations +import pytest + from airflow.models.dag import DAG from airflow.models.dagrun import DagRun from airflow.utils.session import create_session @@ -23,6 +25,8 @@ from airflow.utils.types import DagRunType from tests.models import DEFAULT_DATE +pytestmark = pytest.mark.db_test + def test_runtype_enum_escape(): """ diff --git a/tests/www/api/experimental/test_dag_runs_endpoint.py b/tests/www/api/experimental/test_dag_runs_endpoint.py index 15d08013e8f85..645f3614e57fb 100644 --- a/tests/www/api/experimental/test_dag_runs_endpoint.py +++ b/tests/www/api/experimental/test_dag_runs_endpoint.py @@ -26,6 +26,8 @@ from airflow.models.serialized_dag import SerializedDagModel from airflow.settings import Session +pytestmark = pytest.mark.db_test + class TestDagRunsEndpoint: @pytest.fixture(scope="class", autouse=True) diff --git a/tests/www/api/experimental/test_endpoints.py b/tests/www/api/experimental/test_endpoints.py index a7b879ce69984..f645134a48adf 100644 --- a/tests/www/api/experimental/test_endpoints.py +++ b/tests/www/api/experimental/test_endpoints.py @@ -39,6 +39,8 @@ os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, os.pardir, os.pardir) ) +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def configured_session(): diff --git a/tests/www/test_app.py b/tests/www/test_app.py index 8dd3b57b2e394..571aca79cc392 100644 --- a/tests/www/test_app.py +++ b/tests/www/test_app.py @@ -34,6 +34,8 @@ from tests.test_utils.config import conf_vars from tests.test_utils.decorators import dont_initialize_flask_app_submodules +pytestmark = pytest.mark.db_test + class TestApp: @classmethod diff --git a/tests/www/test_auth.py b/tests/www/test_auth.py index 0a522200d04e7..05a92e0c7ea7d 100644 --- a/tests/www/test_auth.py +++ b/tests/www/test_auth.py @@ -26,6 +26,8 @@ from tests.test_utils.api_connexion_utils import create_user_scope from tests.www.test_security import SomeBaseView, SomeModelView +pytestmark = pytest.mark.db_test + @pytest.fixture(scope="module") def app_builder(app): diff --git a/tests/www/test_init_views.py b/tests/www/test_init_views.py index f50514a527c2d..22d458a665d48 100644 --- a/tests/www/test_init_views.py +++ b/tests/www/test_init_views.py @@ -24,6 +24,8 @@ from airflow.www.extensions import init_views from tests.test_utils.config import conf_vars +pytestmark = pytest.mark.db_test + class TestInitApiExperimental: @conf_vars({("api", "enable_experimental_api"): "true"}) diff --git a/tests/www/test_security.py b/tests/www/test_security.py index e057b76fa89ff..6f6e3ef35bec3 100644 --- a/tests/www/test_security.py +++ b/tests/www/test_security.py @@ -55,6 +55,8 @@ from tests.test_utils.db import clear_db_dags, clear_db_runs from tests.test_utils.mock_security_manager import MockSecurityManager +pytestmark = pytest.mark.db_test + READ_WRITE = {permissions.ACTION_CAN_READ, permissions.ACTION_CAN_EDIT} READ_ONLY = {permissions.ACTION_CAN_READ} diff --git a/tests/www/test_utils.py b/tests/www/test_utils.py index 78f3104dc2e91..19941c15e0d2d 100644 --- a/tests/www/test_utils.py +++ b/tests/www/test_utils.py @@ -24,6 +24,7 @@ from urllib.parse import parse_qs import pendulum +import pytest from bs4 import BeautifulSoup from markupsafe import Markup @@ -157,6 +158,7 @@ def test_state_token(self): assert "<script>alert(1)</script>" in html assert "" not in html + @pytest.mark.db_test def test_task_instance_link(self): from airflow.www.app import cached_app @@ -172,6 +174,7 @@ def test_task_instance_link(self): assert "" not in html assert "" not in html + @pytest.mark.db_test def test_dag_link(self): from airflow.www.app import cached_app @@ -181,6 +184,7 @@ def test_dag_link(self): assert "%3Ca%261%3E" in html assert "" not in html + @pytest.mark.db_test def test_dag_link_when_dag_is_none(self): """Test that when there is no dag_id, dag_link does not contain hyperlink""" from airflow.www.app import cached_app @@ -191,6 +195,7 @@ def test_dag_link_when_dag_is_none(self): assert "None" in html assert "