"""Test for account_statements schema.""" from decimal import Decimal from moneyhub.schemas.account_statements import AccountStatementsDataloaderSchema from moneyhub.schemas.account_statements import AccountStatementsReservesSchema from moneyhub.schemas.account_statements import FlowthroughPayableBalanceSchema from moneyhub.schemas.account_statements import PaymentAllocationDetailSchema def test_account_statements_dataloader_schema(): """Test getting account statements dataloader schema.""" expected_result = AccountStatementsDataloaderSchema( contract_id=48392, statement_period_ids=[290, 291] ) payload = { 'contract_id': 48392, 'statement_period_ids': [290, 291] } actual = AccountStatementsDataloaderSchema(**payload) assert expected_result == actual def test_account_statements_reserves_schema(): """Test getting account statements reserves schema.""" account_id = 123 contract_id = 456 statement_period_id = 298 expected_response = AccountStatementsReservesSchema( ledger_reserve_release_total=Decimal('400.00'), ledger_reserve_taken_total=Decimal('-100.00'), ledger_reserve_total=Decimal('300.00'), account_id=account_id, contract_id=contract_id, statement_period_id=statement_period_id ) data = { 'ledger_reserve_release_total': Decimal('400.00'), 'ledger_reserve_taken_total': Decimal('-100.00'), 'ledger_reserve_total': Decimal('300.00'), 'account_id': account_id, 'contract_id': contract_id, 'statement_period_id': statement_period_id } actual = AccountStatementsReservesSchema(**data) assert expected_response == actual def test_payment_allocation_detail_schema(): """Test getting payment allocation detail schema.""" expected_response = PaymentAllocationDetailSchema( reference_adjustment_type_id=123, apply_to_statement_period_id=11, reference_adjustment_type='Test Adjustment', adjustment_amount=150.00, currency_code='USD' ) data = { 'reference_adjustment_type_id': 123, 'apply_to_statement_period_id': 11, 'reference_adjustment_type': 'Test Adjustment', 'adjustment_amount': Decimal('150.00'), 'currency_code': 'USD' } actual = PaymentAllocationDetailSchema(**data) assert expected_response == actual def test_flowthrough_payable_balance_schema(): """Test parsing the flowthrough payable balance schema.""" expected_response = FlowthroughPayableBalanceSchema( amount=Decimal('123.45'), currency_code='NOK', statement_period_id=123, ) data = { 'amount': Decimal('123.45'), 'currency_code': 'NOK', 'statement_period_id': 123, } actual = FlowthroughPayableBalanceSchema(**data) assert expected_response == actual