"""expenses By subaccount model tests.""" from decimal import Decimal from moneyhub.models import ExpensesBySubaccount from tests.unit.conftest import using_mock_snowflake_table _MOCK_DATA = { 'expenses_by_subaccount_dbt': [ { 'account_id': 57608, 'activity_statement_period_id': 30, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'JPY', 'apply_to_statement_period_id': 10, 'artist_id': 1234567, 'artist_name': 'Best of the best Artist', 'contract_id': 1, 'subaccount_id': 123456, 'reference_adjustment_type_id': 1, 'reference_adjustment_type_name': 'Physical Sales', 'upc': 1234, 'worksheet_adjustment_detail_id': 1 }, { 'account_id': 57608, 'activity_statement_period_id': 10, 'adjustment_amount_payee_currency': Decimal('20.00'), 'adjustment_payee_currency_code': 'GBP', 'apply_to_statement_period_id': 10, 'artist_id': 1234567, 'artist_name': 'Best of the best Artist', 'contract_id': 1, 'subaccount_id': 1234567, 'reference_adjustment_type_id': 1, 'reference_adjustment_type_name': 'Physical Sales', 'upc': 1234, 'worksheet_adjustment_detail_id': 2 }, { 'account_id': 57608, 'activity_statement_period_id': 40, 'adjustment_amount_payee_currency': Decimal('30.00'), 'adjustment_payee_currency_code': 'USD', 'apply_to_statement_period_id': 20, 'artist_id': 1234567, 'artist_name': 'Best of the best Artist', 'contract_id': 1, 'subaccount_id': 12345678, 'reference_adjustment_type_id': 1, 'reference_adjustment_type_name': 'Physical Sales', 'upc': 1234, 'worksheet_adjustment_detail_id': 3 }, ], } ACCOUNT_ID = 57608 @using_mock_snowflake_table(ExpensesBySubaccount, _MOCK_DATA) def test_get_by_subaccount(): """Test getting revenue by account.""" (items, total_record) = ExpensesBySubaccount.get_by_subaccount(ACCOUNT_ID, 50, 0) actual = items[0]._asdict() assert actual == { 'subaccount_id': Decimal('123456'), 'account_id': 57608, 'adjustment_payee_currency_code': 'JPY', 'adjustment_amount_payee_currency': Decimal('10.00'), 'total_records': 3, } @using_mock_snowflake_table(ExpensesBySubaccount, _MOCK_DATA) def test_get_by_subaccount_with_filters(): """Test getting by account with filters.""" contract_id = 1 statement_period_id_start = 20 statement_period_id_end = 30 artist_id = 1234567 (items, total_record) = ExpensesBySubaccount.get_by_subaccount( ACCOUNT_ID, 50, 0, contract_id, statement_period_id_start, statement_period_id_end, artist_id=artist_id ) actual = items[0]._asdict() assert actual == { 'subaccount_id': Decimal('12345678'), 'account_id': 57608, 'adjustment_payee_currency_code': 'USD', 'adjustment_amount_payee_currency': Decimal('30.00'), 'total_records': 1, }