"""Test Setup.""" from typing import Any import pytest from dotenv import load_dotenv from sync_contract_sap.schemas import ContractSyncRow load_dotenv() @pytest.fixture def mock_event() -> dict[str, Any]: """Mock an event.""" return { 'abacus_event_id': 1, 'target_type': 'contract', 'target_id': '201', 'event_name': 'sap_sync', 'timestamp': '2020-01-10T01:12:25.15+01:00', 'user_type': 'royalties', 'user_id': '1', } @pytest.fixture def mock_sap_formatted_contract() -> dict[str, Any]: """Mock a contract in SAP-friendly format.""" return { 'ContractId': 1, 'AccountId': 11, 'ContractName': 'Test contract', 'ContractType': 'distribution', 'DateFrom': '2022-08-30', 'DateTo': '2023-08-30', 'Bukrs': None, 'Prctr': None, 'BusUnit': None, 'Zzfield1': None, 'Zzfield2': None, 'Zzfield3': None, } @pytest.fixture def mock_account() -> dict[str, Any]: """Mock an account.""" return { 'account_id': 11, 'account_name': 'Test account', 'sap_created_at': '2022-09-06', 'account_payee_id': 2, 'account_payment_term_id': 3, } @pytest.fixture def mock_contract() -> dict[str, Any]: """Mock a contract.""" return { 'contract_id': 1, 'account_id': 11, 'contract_name': 'Test contract', 'contract_type': 'distribution', 'reference_sap_profit_center_id': 1, 'sap_created_at': None, 'term_start': '2022-08-30', 'term_end': '2023-08-30', } @pytest.fixture def mock_sap_formatted_account() -> dict[str, Any]: """Mock an account in SAP-friendly format.""" return { 'AccountId': 11, 'AcctName': 'test account', 'Kunnr': None, 'Lifnr': None, 'Zzfield1': None, 'Zzfield2': None, } @pytest.fixture def mock_abacus_states() -> list[dict[str, Any]]: """Mock a set of abacus states.""" return [ { 'action_name': 'sap_sync', 'abacus_state_id': 1, 'action_status': 'init', 'parent_table_id': '1', 'parent_table_name': 'contract', }, { 'action_name': 'sync_contract', 'abacus_state_id': 2, 'action_status': 'init', 'parent_table_id': '1', 'parent_table_name': 'contract', }, ] @pytest.fixture def mock_action_state() -> dict[str, Any]: """Mock an abacus state.""" return { 'action_name': 'sap_sync', 'abacus_state_id': 1, 'action_status': 'init', 'parent_table_id': '1', 'parent_table_name': 'contract', } @pytest.fixture def mock_batch_row() -> ContractSyncRow: """Mock a batch query row where the sap_sync state already exists.""" return ContractSyncRow( contract_id=1, contract_type='distribution', account_id=11, sap_created_at=None, abacus_state_id=42, action_status='init', state_created_at=None, state_last_modified=None, ) @pytest.fixture def mock_batch_row_no_state() -> ContractSyncRow: """Mock a batch query row where no sap_sync state exists yet.""" return ContractSyncRow( contract_id=2, contract_type='publishing', account_id=22, sap_created_at=None, abacus_state_id=None, action_status=None, state_created_at=None, state_last_modified=None, )