"""Accounting Period Report model tests.""" from royalties.constants import constants from royalties.models.accounting_period_report import AccountingPeriodReport from royalties.tests.utils.factories import ( AccountingPeriodFactory, AccountingPeriodReportFactory, ) def test_create(): """Create an accounting period report.""" accounting_period = AccountingPeriodFactory.create() AccountingPeriodReport( accounting_period=accounting_period, report_export_url='s3://main/report_file/', report_type=constants.REPORT_TYPE.VAT_EXEMPT, ) assert len(AccountingPeriodReport.query.all()) == 1 def test_get_acc_period_reports(): """Get accounting period reports by period_id and report_type.""" accounting_period = AccountingPeriodFactory.create() AccountingPeriodReportFactory.create( accounting_period=accounting_period, report_export_url='s3://main/report_file_1/', report_type=constants.REPORT_TYPE.VAT_EXEMPT, ) report_2 = AccountingPeriodReportFactory.create( accounting_period=accounting_period, report_export_url='s3://main/report_file_2/', report_type=constants.REPORT_TYPE.VAT_APPLIED_GBR, ) result = AccountingPeriodReport.get_acc_period_reports( accounting_period.accounting_period_id, constants.REPORT_TYPE.VAT_APPLIED_GBR ).all() assert len(result) == 1 assert result[0].accounting_period_report_id == report_2.accounting_period_report_id