"""Test Setup.""" from decimal import Decimal from dotenv import load_dotenv import pytest load_dotenv() @pytest.fixture def mock_event(): """Mock an event.""" return { 'abacus_event_id': 1, 'target_type': 'payment_group_payment', 'target_id': '1', 'event_name': 'payments_posted', 'timestamp': '1997-07-16T19:20:30.45+01:00', 'user_type': 'royalties', 'user_id': '1' } @pytest.fixture def mock_payment_group_payment_accounts(): """Mock results from payment-group-payment accounts.""" return [ { 'account_id': '123', 'account_name': '(SME Sweden) GMG Sweden AB', 'account_payee_id': '12', 'balance_after_tax': '667686.00', 'contracts_payable': [ { 'contract_id': 829, 'currency_code': 'CAD', 'current_balance': '667686.00' } ], 'current_balance': '667686.00', 'currency_code': 'CAD', 'currency_name': 'Canadian Dollar', 'last_payment': '0.00', 'note': 'test', 'payment_group_payment_account_id': '17', 'payment_group_payment_id': '1', 'payment_difference': 'null', 'payoneer_payee_id': '1', 'payoneer_program_id': '100158940', 'percent_difference': '45%', 'tax_withholding': '0.00' }, { 'account_id': '124', 'account_name': 'Lifestyle Music Pty Ltd', 'account_payee_id': '13', 'balance_after_tax': '786865.00', 'current_balance': '789865.00', 'currency_code': 'GBP', 'currency_name': 'Pound Sterling', 'last_payment': '0.00', 'note': 'test', 'payment_difference': '789.00', 'payment_group_payment_account_id': '18', 'payment_group_payment_id': '1', 'payoneer_payee_id': '2', 'payoneer_program_id': '100158970', 'percent_difference': '46%', 'tax_withholding': '4000.00' } ] @pytest.fixture def mock_payoneer_mass_payouts(): """Mock mass payouts request body.""" return [ { 'client_reference_id': '1', 'account_payee_id': '1', 'currency': 'CAD', 'amount': Decimal('667686.00'), 'description': 'Mass Payout For program 111333555' }, { 'client_reference_id': '2', 'account_payee_id': '2', 'currency': 'GBP', 'amount': Decimal('789865.00'), 'description': 'Mass Payout For program 111333555' } ] @pytest.fixture def mock_abacus_states(): """Mock abacus_state request body.""" return [ { 'action_name': 'send_payment', 'action_status': 'init', 'parent_table_id': '1', 'parent_table_name': 'payment_group_payment_account' }, { 'action_name': 'send_payment', 'action_status': 'init', 'parent_table_id': '2', 'parent_table_name': 'payment_group_payment_account' }, { 'action_name': 'calculate_payments', 'action_status': 'init', 'parent_table_id': '1', 'parent_table_name': 'payment_group_payment_account' } ] @pytest.fixture def mock_debit_ledger(): """Mock debit ledger request body.""" return [ { 'abacus_event_id': 9389, 'account_id': 67624, 'contract_id': 534587, 'currency_amount': -4.75, 'currency_code': 'USD', 'model_type': 'account' }, { 'abacus_event_id': 9389, 'account_id': 67624, 'contract_id': 534593, 'currency_amount': -45.88, 'currency_code': 'USD', 'model_type': 'account' } ] @pytest.fixture def mock_debit_ledger_bad_response(): """Return an example of bad response from creating ledger entries.""" return [{'this': 'mock'}] @pytest.fixture def mock_payoneer_mass_payouts_bad_response(): """Return an example of bad response from Payoneer on mass payouts.""" return { 'code': 'error', 'message': [ { 'code': 1000, 'target': 'payments[0].amount', 'message': 'The specified condition was not met for "amount".', 'client_reference_id': '1' }, { 'code': 1000, 'target': 'payments[1].description', 'message': '"description" must not be empty.', 'client_reference_id': '2' } ] } @pytest.fixture def mock_payment_group_payment_batch(): """Return an example of POST payment batch response.""" return { 'payment_group_payment_batch_id': 1, 'payment_group_payment_id': 1, 'batch_num': 2 } @pytest.fixture def mock_payment_group_payment_batch_account(): """Return an example of POST payment batch accounts response.""" return [ { 'payment_group_payment_batch_account_id': 1, 'payment_group_payment_account_id': 111, 'payment_group_payment_batch_id': 3 }, { 'payment_group_payment_batch_account_id': 2, 'payment_group_payment_account_id': 222, 'payment_group_payment_batch_id': 4 } ] @pytest.fixture def mock_payment_group_payment_batch_state(): """Return an example of payment batch state response.""" return [ { 'action_name': 'send_payment', 'action_status': 'init', 'message': None, 'abacus_state_id': 1, 'parent_table_name': 'payment_group_payment_batch', 'parent_table_id': 1 } ] @pytest.fixture def mock_payment_group_payment(): """Return an example of payment group payment response.""" return { 'created_at': '2023-11-22', 'payment_group_payment_id': 1, 'payment_group_id': 2, 'statement_period_id': 298, 'payment_name': 'KNR UK - October 2023' } @pytest.fixture def mock_knr_payment_group(): """Return an example of a KNR payment group response.""" return { 'group_criteria': { 'reference_payment_entities': [4] }, 'group_name': 'KNR NL', 'is_reusable': True, 'payment_group_id': 2 } @pytest.fixture def mock_payment_group_with_payment_type(): """Return an example of a Check Payments payment group response.""" return { 'group_criteria': { 'reference_payment_type_id': 10 }, 'group_name': 'Check Payments', 'is_reusable': True, 'payment_group_id': 3 } @pytest.fixture def mock_alt_payment_group(): """Return an example of a payment group response.""" return { 'group_criteria': {'account_id': '123'}, 'group_name': 'Other account group', 'is_reusable': False, 'payment_group_id': 2 } @pytest.fixture def mock_payment_entity(): """Return an example of a payment entity response.""" return { 'reference_payment_entity_id': 4, 'payment_entity_name': 'KNR-NL' } @pytest.fixture def mock_alt_payment_entity(): """Return an example of a payment entity response.""" return { 'reference_payment_entity_id': 1, 'payment_entity_name': 'AWAL-UK' }