"""Payments model tests.""" from datetime import date from datetime import datetime from moneyhub.models import Payments from tests.unit.conftest import using_mock_snowflake_table _MOCK_DATA = { 'payments_dbt': [ { 'ledger_account_id': 1, 'account_id': 10, 'contract_id': 1, 'currency_code': 'USD', 'currency_amount': -5000.00, 'created_at': datetime(2022, 1, 1, 11, 55, 55), 'statement_period_id': 20, 'event_name': 'send_payments', 'action_status': 'complete', 'withholding_tax_ledger_account_id': 3, 'withholding_tax_currency_code': 'USD', 'withholding_tax_currency_amount': -1000.00, 'withholding_tax_created_at': date(2022, 1, 1) }, { 'ledger_account_id': 2, 'account_id': 10, 'contract_id': 2, 'currency_code': 'USD', 'currency_amount': -2000.00, 'created_at': datetime(2022, 1, 2, 12, 11, 15), 'statement_period_id': 20, 'event_name': 'send_payments', 'action_status': 'complete', 'withholding_tax_ledger_account_id': None, 'withholding_tax_currency_code': None, 'withholding_tax_currency_amount': None, 'withholding_tax_created_at': None }, { 'ledger_account_id': 3, 'account_id': 10, 'contract_id': 2, 'currency_code': 'USD', 'currency_amount': -1000.00, 'created_at': datetime(2022, 1, 1, 11, 55, 55), 'statement_period_id': 20, 'event_name': 'send_payments', 'action_status': 'complete', 'withholding_tax_ledger_account_id': None, 'withholding_tax_currency_code': None, 'withholding_tax_currency_amount': None, 'withholding_tax_created_at': None }, { 'ledger_account_id': 4, 'account_id': 10, 'contract_id': 1, 'currency_code': 'USD', 'currency_amount': -2000.00, 'created_at': datetime(2022, 1, 2, 12, 11, 15), 'statement_period_id': 20, 'event_name': 'send_payments', 'action_status': 'complete', 'withholding_tax_ledger_account_id': None, 'withholding_tax_currency_code': None, 'withholding_tax_currency_amount': None, 'withholding_tax_created_at': None }, ] } @using_mock_snowflake_table(Payments, _MOCK_DATA) def test_get_by_account_id_and_statement_periods(): """Test get payments for a specified account with statement period range.""" account_id = 10 statement_period_ids = [10, 20, 30] items = Payments.get_payments_by_account_and_statement_periods( account_id, statement_period_ids, None ) assert [item.ledger_account_id for item in items] == [1, 2, 3, 4]