# Path: tests/pgshovel/streams/fixtures.py
# DEFAULT_PUBLISHER = uuid.uuid1().bytes
# def reserialize(message):
# def copy(message, **replacements):
# def make_message(payload, sequence=1, publisher=DEFAULT_PUBLISHER):
# def make_messages(payloads, publisher=DEFAULT_PUBLISHER):
# def make_batch_messages(batch_identifier, payloads, **kwargs):
# def transactions():
# def message():


import pytest
import psycopg2
import uuid
from copy import deepcopy
from itertools import islice
from kafka import (
    KafkaClient,
    SimpleProducer,
)
from kazoo.client import KazooClient
from kafka import KafkaClient
from tests.pgshovel.fixtures import (
    cluster,
    create_temporary_database
)
from tests.pgshovel.streams.fixtures import (
    batch_identifier,
    make_batch_messages,
    transaction,
)
from pgshovel.administration import (
    create_set,
    get_managed_databases,
    initialize_cluster,
)
from pgshovel.cluster import Cluster
from pgshovel.interfaces.common_pb2 import (
    Column,
    Row,
    Snapshot,
    Tick,
    Timestamp,
)
from pgshovel.interfaces.configurations_pb2 import ReplicationSetConfiguration
from pgshovel.interfaces.streams_pb2 import (
    BeginOperation,
    CommitOperation,
    MutationOperation,
    RollbackOperation,
)
from pgshovel.relay.streams.kafka import KafkaWriter
from pgshovel.replication.loaders.simple import SimpleLoader
from pgshovel.replication.streams.kafka import KafkaStream
from pgshovel.replication.targets.postgresql import PostgreSQLTarget
from pgshovel.utilities.conversions import to_snapshot
    replication_set = ReplicationSetConfiguration()
    replication_set.database.dsn = source_connection.dsn
    replication_set.tables.add(name='auth_user', primary_keys=['id'])
    create_set(cluster, name, replication_set)
    yield name


@pytest.yield_fixture
def loader(cluster, set):
    yield SimpleLoader(cluster, set)


@pytest.yield_fixture
def stream(cluster, set, client):
    topic = str(uuid.uuid4())
    client.ensure_topic_exists(topic)
    yield LimitedKafkaStream(2, cluster, set, ('kafka:9092',), topic, 5)


@pytest.yield_fixture
def target(target_cluster, set, target_connection):
    yield PostgreSQLTarget(target_cluster, set, target_connection)


@pytest.yield_fixture
def client():
    yield KafkaClient('kafka:9092')


@pytest.yield_fixture

# Path: tests/pgshovel/streams/fixtures.py
# DEFAULT_PUBLISHER = uuid.uuid1().bytes
# def reserialize(message):
# def copy(message, **replacements):
# def make_message(payload, sequence=1, publisher=DEFAULT_PUBLISHER):
# def make_messages(payloads, publisher=DEFAULT_PUBLISHER):
# def make_batch_messages(batch_identifier, payloads, **kwargs):
# def transactions():
# def message():


# Path: tests/pgshovel/replication/targets/postgres.py
import pytest
import psycopg2
import uuid
from copy import deepcopy
from itertools import islice
from kafka import (
    KafkaClient,
    SimpleProducer,
)
from kazoo.client import KazooClient
from kafka import KafkaClient
from tests.pgshovel.fixtures import (
    cluster,
    create_temporary_database
)
from tests.pgshovel.streams.fixtures import (
    batch_identifier,
    make_batch_messages,
    transaction,
)
from pgshovel.administration import (
    create_set,
    get_managed_databases,
    initialize_cluster,
)
from pgshovel.cluster import Cluster
from pgshovel.interfaces.common_pb2 import (
    Column,
    Row,
    Snapshot,
    Tick,
    Timestamp,
)
from pgshovel.interfaces.configurations_pb2 import ReplicationSetConfiguration
from pgshovel.interfaces.streams_pb2 import (
    BeginOperation,
    CommitOperation,
    MutationOperation,
    RollbackOperation,
)
from pgshovel.relay.streams.kafka import KafkaWriter
from pgshovel.replication.loaders.simple import SimpleLoader
from pgshovel.replication.streams.kafka import KafkaStream
from pgshovel.replication.targets.postgresql import PostgreSQLTarget
from pgshovel.utilities.conversions import to_snapshot

    replication_set = ReplicationSetConfiguration()
    replication_set.database.dsn = source_connection.dsn
    replication_set.tables.add(name='auth_user', primary_keys=['id'])
    create_set(cluster, name, replication_set)
    yield name


@pytest.yield_fixture
def loader(cluster, set):
    yield SimpleLoader(cluster, set)


@pytest.yield_fixture
def stream(cluster, set, client):
    topic = str(uuid.uuid4())
    client.ensure_topic_exists(topic)
    yield LimitedKafkaStream(2, cluster, set, ('kafka:9092',), topic, 5)


@pytest.yield_fixture
def target(target_cluster, set, target_connection):
    yield PostgreSQLTarget(target_cluster, set, target_connection)


@pytest.yield_fixture
def client():
    yield KafkaClient('kafka:9092')


@pytest.yield_fixture

def writer(client, stream):