"""Test Revenue Base.""" from moneyhub.models import revenue_base from tests.utils.factories import DimSubaccountFactory from tests.utils.factories import RevenueByRecordingNrFactory from tests.utils.factories import RevenueByStatementPeriodFactory from tests.utils.factories import RevenueByStoreFactory def test_apply_subaccount_revenue(): """Test applying subaccount revenue.""" mock_cls = RevenueByStatementPeriodFactory.build(net_revenue_payee_currency=80.0) subaccount_info = DimSubaccountFactory with_entities = [] revenue_base.apply_subaccount_revenue(subaccount_info, with_entities, mock_cls) assert len(with_entities) == 1 assert with_entities[0].name == 'subaccount_revenue' def test_apply_filters(): """Test applying subaccount revenue.""" mock_cls = RevenueByStoreFactory.build() filters = [] revenue_base.apply_filters(mock_cls, filters, artist_id=1, subaccount_id=1) assert len(filters) == 2 def test_apply_filters_project_id_skipped_when_attribute_missing(): """project_id filter is a no-op when the model has no project_id column.""" mock_cls = RevenueByRecordingNrFactory.build() filters = [] revenue_base.apply_filters(mock_cls, filters, project_id=4242) assert filters == []