from kafka.admin import NewTopic
import pytest
from dbdeploy.dtos import ExecutionJob
@pytest.fixture
def mock_xml():
return """
"""
@pytest.fixture
def mock_multi_changeset_xml():
return """
"""
@pytest.fixture
def mock_bad_xml():
return """
"""
@pytest.fixture
def mock_default_neo4j_server_xml():
return """
"""
@pytest.fixture
def mock_unknown_neo4j_server_xml():
return """
"""
@pytest.fixture
def mock_skip_cypher():
return """
"""
@pytest.fixture
def mock_skip_cypher_kafka_cluster_not_set():
return """
"""
@pytest.fixture
def mock_skip_cypher_missing_topic_name():
return """
"""
@pytest.fixture
def mock_skip_snowflake_to_mysql():
return """
test_col1
string
test_col2
string
"""
@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_job():
return ExecutionJob(
changeset_id='test_changeset:1',
id='f007ba11-1111-0000-0000-000000000000',
topic=NewTopic(name='topic_1', num_partitions=1, replication_factor=3), # noqa: E501
dlq_topic=NewTopic(name='dlqtopic_1', 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,
neo4j_server='music-graph',
connector_started=False)
@pytest.fixture
def mock_job_nosql():
return ExecutionJob(
changeset_id='test_changeset:1',
id='f007ba11-1111-0000-0000-000000000000',
topic=NewTopic(name='topic_1', num_partitions=1, replication_factor=3), # noqa: E501
dlq_topic=NewTopic(name='dlqtopic_1', num_partitions=1, replication_factor=3), # noqa: E501
precondition=False,
snowflake_account='orchard',
sql_query=None,
cypher_query='MERGE (t:TestNode {test: event.test_col})',
offsets={},
is_done=False,
topics_created=False,
connector_started=False)
@pytest.fixture
def mock_job_nocypher():
return ExecutionJob(
changeset_id='test_changeset:1',
id='f007ba11-1111-0000-0000-000000000000',
precondition=True,
sql_query='SELECT test_col FROM test_table',
cypher_query=None,
snowflake_account='orchard',
offsets={},
is_done=False,
skip_sink_connector=True,
topic_name='test.TopicName',
topics_created=False,
connector_started=False)
@pytest.fixture
def mock_snowflake_to_mysql_with_upsert():
"""XML fixture with insert-mode="upsert" specified."""
return """
test_col1
string
test_col2
string
"""
@pytest.fixture
def mock_snowflake_to_mysql_with_insert():
"""XML fixture with insert-mode="insert" specified."""
return """
test_col1
string
"""
@pytest.fixture
def mock_snowflake_to_mysql_with_delete():
"""XML fixture with insert-mode="delete" specified."""
return """
test_col1
string
"""
@pytest.fixture
def mock_snowflake_to_mysql_with_invalid_insert_mode():
"""XML fixture with invalid insert-mode specified."""
return """
test_col1
string
"""
@pytest.fixture
def mock_snowflake_to_mysql_default_insert_mode():
"""XML fixture with no insert-mode specified (should default to 'update')."""
return """
test_col1
string
"""