Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Typo in function name #18

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion producer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def produce(pg_host, pg_port, pg_database, pg_user, pg_password, pg_replication_
@click.option('--pg_publication_name', default=lambda: os.environ.get('PGPUBLICATION', None), required=False, help='Restrict to specific publications e.g. events')
@click.option('--rabbitmq_url', default=lambda: os.environ.get('RABBITMQ_URL', None), required=True, help='RabbitMQ url ($RABBITMQ_URL)')
@click.option('--rabbitmq_exchange', default=lambda: os.environ.get('RABBITMQ_EXCHANGE', None), required=True, help='RabbitMQ exchange ($RABBITMQ_EXCHANGE)')
def produce_multiple_dbs(db_configs, pg_output_plugin, pg_publication_name, rabbitmq_url, rabbitmq_exchange):
def producer_multiple_dbs(db_configs, pg_output_plugin, pg_publication_name, rabbitmq_url, rabbitmq_exchange):
try:
db_configs = json.loads(db_configs)
validate_db_configs(db_configs)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
entry_points='''
[console_scripts]
producer=producer.main:produce
producer_multiple_dbs=producer.main:produce_multiple_dbs
producer_multiple_dbs=producer.main:producer_multiple_dbs
event_logger=consumer.main:consume
'''
)
18 changes: 9 additions & 9 deletions tests/test_event_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from common.qconnector.rabbitmq_connector import RabbitMQConnector
from common.utils import validate_db_configs
from producer.event_producer import EventProducer
from producer.main import produce_multiple_dbs
from producer.main import producer_multiple_dbs


# Test init
Expand Down Expand Up @@ -242,19 +242,19 @@ def valid_db_configs():
'pg_replication_slot': 'events'
}])

def test_produce_multiple_dbs_success(valid_db_configs):
def test_producer_multiple_dbs_success(valid_db_configs):
runner = CliRunner()
result = runner.invoke(produce_multiple_dbs, [
result = runner.invoke(producer_multiple_dbs, [
'--db_configs', valid_db_configs,
'--rabbitmq_url', 'amqp://admin:password@rabbitmq:5672/?heartbeat=0',
'--rabbitmq_exchange', 'pgevents_exchange'
])

assert result.exit_code == 0

def test_produce_multiple_dbs_invalid_json():
def test_producer_multiple_dbs_invalid_json():
runner = CliRunner()
result = runner.invoke(produce_multiple_dbs, [
result = runner.invoke(producer_multiple_dbs, [
'--db_configs', 'invalid-json',
'--rabbitmq_url', 'amqp://admin:password@rabbitmq:5672/?heartbeat=0',
'--rabbitmq_exchange', 'pgevents_exchange'
Expand All @@ -263,21 +263,21 @@ def test_produce_multiple_dbs_invalid_json():
assert "db_configs must be a valid JSON string" in str(result.__dict__)

@mock.patch('producer.main.validate_db_configs')
def test_produce_multiple_dbs_invalid_config(mock_validate, valid_db_configs):
def test_producer_multiple_dbs_invalid_config(mock_validate, valid_db_configs):
mock_validate.side_effect = click.BadParameter("Invalid config")

runner = CliRunner()
result = runner.invoke(produce_multiple_dbs, [
result = runner.invoke(producer_multiple_dbs, [
'--db_configs', valid_db_configs,
'--rabbitmq_url', 'amqp://admin:password@rabbitmq:5672/?heartbeat=0',
'--rabbitmq_exchange', 'pgevents_exchange'
])

assert "Invalid config" in str(result.__dict__)

def test_produce_multiple_dbs_common_kwargs(valid_db_configs):
def test_producer_multiple_dbs_common_kwargs(valid_db_configs):
runner = CliRunner()
result = runner.invoke(produce_multiple_dbs, [
result = runner.invoke(producer_multiple_dbs, [
'--db_configs', valid_db_configs,
'--pg_output_plugin', 'test_plugin',
'--pg_publication_name', 'test_pub',
Expand Down
Loading