"""Test fixtures.""" import base64 import json import pytest @pytest.fixture def mock_event(): """Mock contribution created event.""" return { 'contributionId': '0b0478e2-db1c-4980-bd66-180673bd41b8', 'eventType': 'CREATE', 'application': 'graphql-neighbouring-rights', 'applicationVersion': '1.0.0', 'identityId': '1fd5dd8b-877b-432a-9a31-164c8c2d26ef', 'profileId': '100467', 'profileType': 'ContentProfile', 'source': 'graphql-neighbouring-rights' } @pytest.fixture def mock_message(mock_event): """Mock Event source message.""" mock_value = base64.b64encode(bytes(json.dumps(mock_event), 'utf-8')) return { 'eventSource': 'aws:kafka', 'eventSourceArn': 'arn', 'bootstrapServers': 'kafka', 'records': { 'event.nr.contribution.metadata-0': [ { 'topic': 'event.nr.contribution.version', 'partition': 0, 'offset': 0, 'timestamp': 1629227002458, 'timestampType': 'CREATE_TIME', 'headers': [], 'key': '', 'value': mock_value } ] } } @pytest.fixture def mock_contributor_response(): """Mock get contributor schedule graphql response.""" return { 'data': { 'nrContributionById': { 'id': '0b0478e2-db1c-4980-bd66-180673bd41b8', 'nrContributor': { 'id': '90abb34b-b62d-414e-87c3-00000', 'abacusSchedules': [ { 'scheduleId': '1', 'conditions': None }, { 'scheduleId': '2', 'conditions': {'autoAdd': True} }, { 'scheduleId': '3', 'conditions': {'autoAdd': False} } ] }, 'valid': True } } } @pytest.fixture def mock_contributor_invalid_contribution_response(): """Mock get contributor schedule graphql response for invalid contribution.""" # noqa: E501 return { 'data': { 'nrContributionById': { 'id': 'f7bd1732-af8f-498b-b11b-3a5822e95d25', 'nrContributor': { 'id': 'ecfaed03-1b5a-44b6-8b8c-f9b7984935f2', 'abacusSchedules': [] }, 'valid': False } } } @pytest.fixture def mock_contributor_none_invalid_contribution_response(): """Mock get contributor schedule graphql response for invalid contribution resulting in none.""" # noqa: E501 return { 'data': { 'nrContributionById': { 'id': 'f7bd1732-af8f-498b-b11b-3a5822e95d25', 'nrContributor': { 'id': 'ecfaed03-1b5a-44b6-8b8c-f9b7984935f2', 'abacusSchedules': [] }, 'valid': None } } }