"""combined adjustments model tests.""" from decimal import Decimal from moneyhub.models import CombinedAdjustments from tests.unit.conftest import using_mock_snowflake_table _MOCK_DATA = { 'combined_adjustments_dbt': [ { 'account_id': 57608, 'activity_statement_period_id': 8, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'JPY', 'apply_to_statement_period_id': 10, 'contract_id': 1, 'reference_adjustment_type_id': 1, 'reference_adjustment_type_name': 'Physical Sales', 'worksheet_adjustment_id': 1, 'ledger_adjustment_applied_id': 1, 'unique_identifier': '123' }, { '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': 11, 'contract_id': 1, 'reference_adjustment_type_id': 1, 'reference_adjustment_type_name': 'Physical Sales', 'worksheet_adjustment_id': 2, 'ledger_adjustment_applied_id': 2, 'unique_identifier': '456' }, { 'account_id': 57608, 'activity_statement_period_id': 18, 'adjustment_amount_payee_currency': Decimal('30.00'), 'adjustment_payee_currency_code': 'USD', 'apply_to_statement_period_id': 20, 'contract_id': 1, 'reference_adjustment_type_id': 2, 'reference_adjustment_type_name': 'Digital Sales', 'worksheet_adjustment_id': 3, 'ledger_adjustment_applied_id': 3, 'unique_identifier': '789' }, ], } ACCOUNT_ID = 57608 VISIBLE_PERIODS = [10, 20, 30] @using_mock_snowflake_table(CombinedAdjustments, _MOCK_DATA) def test_get_by_account_id(): """Test to get ledger adjustments for a specified account.""" account_id = 57608 statement_period_id_start = 10 statement_period_id_end = 12 res = CombinedAdjustments.get_by_account_id( account_id, None, statement_period_id_start, statement_period_id_end, None) assert len(res) == 2 assert all(entry.account_id == account_id for entry in res) @using_mock_snowflake_table(CombinedAdjustments, _MOCK_DATA) def test_get_adjustments_types_by_account_id(): """Test to get associated adjustments types for adjustments for a given account.""" account_id = 57608 result = CombinedAdjustments.get_adjustments_types_by_account_id( account_id) assert len(result) == 2 assert [dict(item) for item in result] == [ { 'reference_adjustment_type_id': 1, 'type_name': 'Physical Sales', }, { 'reference_adjustment_type_id': 2, 'type_name': 'Digital Sales', } ]