"""Pytest fixtures for detect_errors unit tests.""" import json import pytest @pytest.fixture def sm_context(): """Minimal valid GRPS state machine context.""" return { 'correlation_id': 'test-correlation-id', 'grps_ingestion_id': 1, 'project': { 'name': 'Test Project', 'project_code': '123', 'project_id': 1000000, }, 'product': { 'product_id': 9999999, 'upc': '196871691208', 'product_name': 'Test Album', }, 'tracks': [ {'isrc': 'QZCDB2000001', 'tuid': 11111111, 'track_name': 'Track 1'}, {'isrc': 'QZCDB2000002', 'tuid': 22222222, 'track_name': 'Track 2'}, {'isrc': 'QZCDB2000003', 'tuid': 33333333, 'track_name': 'Track 3'}, ], 'label_participants': [], } @pytest.fixture def track_error(): """SFN error from CatchSetTrackMetadataError -> Succeed.""" return { 'Error': 'SetTrackMetadataException', 'Cause': json.dumps({ 'errorMessage': 'GraphQL error for ISRC QZCDB2000002', 'errorType': 'SetTrackMetadataException', 'stackTrace': [ 'File "/var/task/src/index.py", line 70, in handler' ], }), } @pytest.fixture def upstream_error(): """SFN error from ResultPath=$.errors on an upstream Catch.""" return { 'Error': 'ProductAlreadyExistsException', 'Cause': json.dumps({ 'errorMessage': 'Product already exists with upc: 196871691208', 'errorType': 'ProductAlreadyExistsException', 'stackTrace': [ 'File "/var/task/src/index.py", line 48, in handler' ], }), }