"""Application tests fixtures.""" from unittest.mock import patch from kafka.admin import NewTopic import pytest from dbdeploy.dtos import ExecutionJob @pytest.fixture def mock_cleanup_runs(): path = 'application.clean_up_previous_runs' with patch(path) as mock: yield mock @pytest.fixture def mock_joblist(): return [ ExecutionJob( changeset_id='test_changeset:1', id='f007ba11-1111-0000-0000-000000000000', topic=NewTopic(name=None, num_partitions=1, replication_factor=3), # noqa: E501 dlq_topic=NewTopic(name=None, num_partitions=1, replication_factor=3), # noqa: E501 precondition=True, snowflake_account='orchard', sql_query='SELECT test_col FROM test_table', cypher_query='MERGE (t:TestNode {test: event.test_col})', offsets={}, is_done=False, topics_created=False, connector_started=False), ExecutionJob( changeset_id='test_changeset:2', id='f007ba11-2222-0000-0000-000000000000', topic=NewTopic(name=None, num_partitions=1, replication_factor=3), # noqa: E501 dlq_topic=NewTopic(name=None, num_partitions=1, replication_factor=3), # noqa: E501 precondition=True, snowflake_account='orchard', sql_query='SELECT test_col FROM test_table', cypher_query='MERGE (t:TestNode {test: event.test_col})', offsets={}, is_done=False, topics_created=False, connector_started=False)] @pytest.fixture def mock_monitor_dlq(): path = 'application.monitor_dlq' with patch(path) as mock: yield mock @pytest.fixture def mock_create_topics(): path = 'application.create_kafka_topics' with patch(path) as mock: yield mock @pytest.fixture def mock_delete_topics(): path = 'application.delete_kafka_topics' with patch(path) as mock: yield mock @pytest.fixture def mock_prepare_job_list(): path = 'application.prepare_job_list' with patch(path) as mock: yield mock @pytest.fixture def mock_parse_file(): path = 'application.parse_db_pr_file' with patch(path) as mock: yield mock @pytest.fixture def mock_push_kafka(): path = 'application.push_to_kafka' with patch(path) as mock: yield mock @pytest.fixture def mock_acquire_lock(): path = 'application.acquire_deploy_lock' with patch(path) as mock: yield mock @pytest.fixture def mock_start_connector(): path = 'application.start_kafka_connector' with patch(path) as mock: yield mock @pytest.fixture def mock_release_lock(): path = 'application.release_deploy_lock' with patch(path) as mock: yield mock @pytest.fixture def mock_stop_connector(): path = 'application.stop_kafka_connector' with patch(path) as mock: yield mock @pytest.fixture def mock_track_offsets(): path = 'application.track_kafka_consumer_offsets' with patch(path) as mock: yield mock @pytest.fixture def mock_get_jobs_statuses(): path = 'application.get_jobs_statuses' with patch(path) as mock: yield mock @pytest.fixture def mock_update_job_status(): path = 'application.update_job_status' with patch(path) as mock: yield mock @pytest.fixture def mock_check_topic_exists(): path = 'application.check_kafka_topic_exists' with patch(path) as mock: yield mock @pytest.fixture def mock_update_kafka_config(): path = 'application.update_kafka_cluster_config' with patch(path) as mock: yield mock