"""Test Setup.""" from decimal import Decimal from dotenv import load_dotenv import pytest from correction_apply.config import LEDGER_TYPES load_dotenv() @pytest.fixture def mock_event(): """Mock an event.""" return { 'abacus_event_id': 1, 'target_type': 'statement_period', 'target_id': '2', 'event_name': 'apply_royalty_reversal', 'timestamp': '2020-01-10T01:12:25.15+01:00', 'user_type': 'royalties', 'user_id': '1' } @pytest.fixture def mock_ledger_account_contract(): """Mock ledger_account_contract entry.""" return { 'abacus_event_id': 1, 'account_id': 1, 'contract_id': 1, 'currency_amount': Decimal('16.90'), 'currency_code': 'USD', 'model_type': LEDGER_TYPES.ACCOUNT } @pytest.fixture def mock_ledger_deposit(): """Mock ledger_deposit entry.""" return { 'abacus_event_id': 1, 'account_id': 1, 'contract_id': 1, 'currency_code': 'USD', 'model_type': LEDGER_TYPES.DEPOSIT, 'remaining_amount': Decimal('-0.008903000000000000'), 'rounded_amount': Decimal('16.90') } @pytest.fixture() def mock_ledger_params(): """Mock ledger params for creating ledger entries.""" return { 'account_ledger_amount': Decimal('16.90'), 'remainder': Decimal('-0.008903000000000000'), 'rounded_amount': Decimal('16.90'), 'worksheet_correction_id': 1, 'account_id': 1, 'contract_id': 1, 'statement_period_id': 2, 'correction_statement_period_id': 1, 'currency_code': 'USD', 'correction_type': 'royalty_reversal', 'gross_revenue': '20.09', 'distribution_fee': '-3.20', 'mechanical_deduction_total': '-100.90', 'mechanical_deduction_admin_fee_total': '-45.14', 'net_revenue': '16.90', 'note': None } @pytest.fixture def mock_worksheet_correction(): """Mock worksheet_correction data.""" return { 'worksheet_correction_id': 1, 'account_id': 1, 'contract_id': 1, 'statement_period_id': 2, 'correction_statement_period_id': 1, 'currency_code': 'USD', 'correction_type': 'royalty_reversal', 'gross_revenue': '20.089799000000000000', 'distribution_fee': '-3.198702000000000000', 'mechanical_deduction_total': '-100.898970000000000000', 'mechanical_deduction_admin_fee_total': '-45.138767800000000000', 'net_revenue': '16.891097000000000000', 'note': None } @pytest.fixture def mock_ledger_correction(): """Mock ledger_correction data.""" return { 'abacus_event_id': 1, 'worksheet_correction_id': 1, 'account_id': 1, 'contract_id': 1, 'statement_period_id': 2, 'correction_statement_period_id': 1, 'correction_type': 'royalty_reversal', 'currency_code': 'USD', 'gross_revenue': '20.09', 'distribution_fee': '-3.20', 'mechanical_deduction_total': '-100.90', 'mechanical_deduction_admin_fee_total': '-45.14', 'net_revenue': '16.90', 'note': None }