"""AccountPaymentTerm model tests.""" from abacus_account.models.account_payment_term import AccountPaymentTerm from abacus_account.tests.utils.factories import ( AccountFactory, AccountPaymentTermFactory, ) def test_create(reference_payment_entity_fixture): """Test to create an account payment term.""" account = AccountFactory.create() AccountPaymentTerm.create( account_id=account.account_id, currency_code='USD', payment_minimum='350', payment_schedule='30_days_after_month_end', payment_entity_id=5, ) results = AccountPaymentTerm.query.all() assert len(results) == 1 def test_create_partial(): """Test to create an account payment term with some null values.""" account = AccountFactory.create() AccountPaymentTerm.create( account_id=account.account_id, currency_code='USD', payment_entity_id=None, payment_minimum=None, payment_schedule='30_days_after_month_end', ) results = AccountPaymentTerm.query.all() assert len(results) == 1 def test_stream_all(account_fixtures, reference_payment_entity_fixture): """Test to get account payment terms by account ids if specified.""" for account in account_fixtures: AccountPaymentTermFactory.create(account=account) results = AccountPaymentTerm.stream_all().all() assert len(list(results)) == len(account_fixtures) results_filtered = AccountPaymentTerm.stream_all((1, 2, 777)) assert len(list(results_filtered)) == 2