"""Test Setup.""" from decimal import Decimal import os from dotenv import load_dotenv import pytest load_dotenv() os.environ['ENVIRONMENT'] = 'test' os.environ['ORCHARD_IDENTITY_ID'] = 'Test-ID' os.environ['SNOWFLAKE_DATABASE'] = 'SNOWFLAKE_DB' os.environ['SNOWFLAKE_SCHEMA'] = 'dev' @pytest.fixture def mock_event(): """Mock an event.""" return { 'abacus_event_id': 1, 'target_type': 'accounting_run', 'target_id': '1506', 'event_name': 'accounting_run_calculate', 'timestamp': '1997-07-16T19:20:30.45+01:00', 'user_type': 'royalties', 'user_id': '1' } @pytest.fixture def mock_ledger_entry(): """Mock ledger entry.""" return { 'payee_id': 1, 'abacus_event_id': 1, 'ledger_type': 'credit', 'currency_code': 'USD', 'currency_amount': Decimal('191.02'), 'previous_balance': Decimal('0'), 'current_balance': Decimal('191.02'), 'note': None } @pytest.fixture def mock_results(): """Mock results.""" return [ { 'abacus_event_id': 1, 'contract_id': 1, 'currency_code': 'USD', 'total_gross_revenue_amount': '180.99', 'mechanical_deduction_total': '-32.13', 'mechanical_deduction_admin_fee_total': '-60.00', 'total_net_revenue_amount': '168.86', 'distribution_fee': '-12.14', 'adjusted_net_revenue': '76.73' }, { 'abacus_event_id': 1, 'contract_id': 2, 'currency_code': 'USD', 'total_gross_revenue_amount': '111.90', 'mechanical_deduction_total': '-10.10', 'mechanical_deduction_admin_fee_total': '-2.00', 'total_net_revenue_amount': '110.12', 'distribution_fee': '-1.79', 'adjusted_net_revenue': '98.02' } ] @pytest.fixture def mock_contracts(): """Mock results from snowflake query.""" return [ { 'CONTRACT_ID': 1, 'CURRENCY_CODE': 'USD', 'TOTAL_GROSS_REVENUE_AMOUNT': Decimal('180.98700000000'), 'MECHANICAL_DEDUCTION_TOTAL': Decimal('-32.123000000000'), 'MECHANICAL_DEDUCTION_ADMIN_FEE_TOTAL': Decimal('-60.000000000000'), 'TOTAL_NET_REVENUE_AMOUNT': Decimal('168.852000000000'), 'DISTRIBUTION_FEE': Decimal('-12.135000000000'), 'ADJUSTED_NET_REVENUE': Decimal('76.729000000') }, { 'CONTRACT_ID': 2, 'CURRENCY_CODE': 'USD', 'TOTAL_GROSS_REVENUE_AMOUNT': Decimal('111.900000000000'), 'MECHANICAL_DEDUCTION_TOTAL': Decimal('-10.100000000000'), 'MECHANICAL_DEDUCTION_ADMIN_FEE_TOTAL': Decimal('-2.000000000000'), 'TOTAL_NET_REVENUE_AMOUNT': Decimal('110.115000000000'), 'DISTRIBUTION_FEE': Decimal('-1.785000000000'), 'ADJUSTED_NET_REVENUE': Decimal('98.015000000000') } ] @pytest.fixture def mock_contract_list(): """Mock list of distinct contract ids.""" return [ {'CONTRACT_ID': 1}, {'CONTRACT_ID': 2}, {'CONTRACT_ID': 4}, ]