"""Shared test mocks.""" import json import pytest def load_file(filepath): """Load file.""" with open(filepath) as event_file: return event_file.read() def load_file_json(filepath): """Load json from file.""" return json.loads(load_file(filepath)) @pytest.fixture def mock_cdc_event(): """Mock event.""" return load_file_json('tests/sample_cdc_msk_event.json') @pytest.fixture def mock_record(): """Mock record.""" return load_file_json('tests/sample_event.json') @pytest.fixture def mock_empty_event(): """Mock empty event.""" return load_file_json('tests/sample_empty_msk_event.json') @pytest.fixture def mock_row_data(): """Mock row data.""" return { 'id': 1, 'product_id': 1, 'review_queue_id': 2, 'status': 'new', 'created_datetime': '2021-08-03T01:13:14Z' } @pytest.fixture def mock_indexing_data_inputs(): """Mock indexing data inputs.""" return [ { 'product_id': 2, 'review_queue_id': 2, 'payload': None, 'operation_type': 'deindex' }, { 'product_id': 3, 'review_queue_id': 3, 'payload': { 'id': 3, 'product_id': 3, 'status': 'new', 'created_datetime': '2021-08-03T01:13:14Z' }, 'operation_type': 'add_to_index' }, { 'product_id': 4, 'review_queue_id': 4, 'payload': None, 'operation_type': 'deindex' } ] @pytest.fixture def mock_sfn_execution_arn(): """Mock state machine arn execution.""" return { 'executionArn': 'arn:aws:states:us-east-1:123456789012:execution:my-execution', } @pytest.fixture def mock_sqs_add_result(): """Mock result for add_to_store_product_queue.""" return { 'MessageId': 'Random-mock-id-123' }