"""Shared test mocks.""" import json import pytest def load_file(filepath): """Load file.""" with open(filepath) as event_file: read_data = event_file.read() return read_data def load_file_json(filepath): """Load json from file.""" return json.loads(load_file(filepath)) @pytest.fixture def mock_event(): """Mock event.""" return load_file_json('tests/sample_event.json') @pytest.fixture def mock_ineligible_event_list(): """Mock ineligible event.""" a = load_file_json('tests/sample_1_ineligible_event.json') b = load_file_json('tests/sample_2_ineligible_event.json') return [a, b] @pytest.fixture def mock_de_escalate_event(): """Mock de-escalate event.""" return load_file_json('tests/sample_de_escalate_event.json') @pytest.fixture def mock_product(): """Mock product.""" return { 'data': { 'product': { 'upc': '99999', 'productName': 'some product', 'label': { 'id': { 'vendorId': 2, }, 'name': 'sample label' }, 'artists': [ { 'artistId': '1', 'artistName': 'XYZ Artist', 'artistType': 'primary_artist' }, { 'artistId': '2', 'artistName': 'Second ABC Artist', 'artistType': 'composer' } ], 'saleStartDate': '2021-11-08' } } } @pytest.fixture def mock_review_queue_item(): """Mock review queue item.""" return { 'productId': 1, 'movedToQueueByIdentity': { 'firstName': 'foo', 'lastName': 'baz' }, 'movedToTarget': { 'escalationType': 'some target', 'targetGroup': { 'displayName': 'some group' } }, 'moveNote': 'sample note xyz' } @pytest.fixture def mock_item_no_target(): """Mock review queue item.""" return { 'productId': 1, 'movedToQueueByIdentity': { 'firstName': 'foo', 'lastName': 'baz' }, 'movedToTarget': None, 'moveNote': 'sample note xyz' }