"""Workstation summary model tests.""" from decimal import Decimal from moneyhub.models import WorkstationSummary from tests.unit.conftest import using_mock_snowflake_table ACCOUNT_ID = 24601 _MOCK_DATA = { 'workstation_summary_dbt': [ { 'account_id': 24601, 'account_name': 'Account Name', 'contract_id': 10001, 'statement_period_id': 10, 'currency': 'USD', 'opening_balance': Decimal('100.00'), 'payments': Decimal('8.00'), 'net_revenue': Decimal('8.00'), 'gross_revenue': Decimal('7.00'), 'fee': Decimal('2.00'), 'expenses': Decimal('20.00'), 'adjustments': Decimal('12.00'), 'closing_balance': Decimal('80.00'), 'mechanicals': Decimal('0.00'), 'mechanical_fees': Decimal('0.00'), }, { 'account_id': 24601, 'account_name': 'Account Name', 'contract_id': 10001, 'statement_period_id': 11, 'currency': 'USD', 'opening_balance': Decimal('100.00'), 'payments': Decimal('8.00'), 'net_revenue': Decimal('8.00'), 'gross_revenue': Decimal('7.00'), 'fee': Decimal('2.00'), 'expenses': Decimal('20.00'), 'adjustments': Decimal('12.00'), 'closing_balance': Decimal('80.00'), 'mechanicals': Decimal('0.00'), 'mechanical_fees': Decimal('0.00'), }, { 'account_id': 24601, 'account_name': 'Account Name', 'contract_id': 10001, 'statement_period_id': 12, 'currency': 'USD', 'opening_balance': Decimal('100.00'), 'payments': Decimal('8.00'), 'net_revenue': Decimal('8.00'), 'gross_revenue': Decimal('7.00'), 'fee': Decimal('2.00'), 'expenses': Decimal('20.00'), 'adjustments': Decimal('12.00'), 'closing_balance': Decimal('80.00'), 'mechanicals': Decimal('10.00'), 'mechanical_fees': Decimal('2.00'), } ] } @using_mock_snowflake_table(WorkstationSummary, _MOCK_DATA) def test_get_balances_by_account_id(): """Test getting balances for an account.""" expected = [ { 'statement_period_id': 10, 'currency': 'USD', 'opening_balance': Decimal('100.00'), 'closing_balance': Decimal('80.00'), }, { 'statement_period_id': 11, 'currency': 'USD', 'opening_balance': Decimal('100.00'), 'closing_balance': Decimal('80.00'), }, ] account_id = 24601 statement_period_ids = [10, 11] contract_id = 10001 items = WorkstationSummary.get_balances_by_account_id( account_id, statement_period_ids, contract_id) assert [item._asdict() for item in items] == expected @using_mock_snowflake_table(WorkstationSummary, _MOCK_DATA) def test_get_revenue_for_account(): """Test getting revenue for an account.""" expected = [ { 'statement_period_id': 10, 'currency': 'USD', 'net_revenue': Decimal('8.00'), 'gross_revenue': Decimal('7.00'), 'fee': Decimal('2.00'), 'mechanicals': Decimal('0.00'), 'mechanical_fees': Decimal('0.00'), }, { 'statement_period_id': 11, 'currency': 'USD', 'net_revenue': Decimal('8.00'), 'gross_revenue': Decimal('7.00'), 'fee': Decimal('2.00'), 'mechanicals': Decimal('0.00'), 'mechanical_fees': Decimal('0.00'), }, { 'statement_period_id': 12, 'currency': 'USD', 'net_revenue': Decimal('8.00'), 'gross_revenue': Decimal('7.00'), 'fee': Decimal('2.00'), 'mechanicals': Decimal('10.00'), 'mechanical_fees': Decimal('2.00'), }, ] account_id = 24601 items = WorkstationSummary.get_revenue_for_account( account_id, None, None) assert [item._asdict() for item in items] == expected