"""Tests Account Tax Info History model.""" from abacus_account.models.account_tax_info_history import AccountTaxInfoHistory from tests.utils.factories import AccountTaxInfoFactory, AccountTaxInfoHistoryFactory def test_get_account_tax_info_history_by_id(): """Test GET account_tax_info_history by account_id.""" object_id = 1 assert len(AccountTaxInfoHistory.query.all()) == 0 account_tax_info_history = AccountTaxInfoHistoryFactory.create( account_tax_info_history_id=object_id ) assert len(AccountTaxInfoHistory.query.all()) == 1 result = AccountTaxInfoHistory.get_by_id(object_id) assert result.account_tax_info_history_id == \ account_tax_info_history.account_tax_info_history_id assert result.account_tax_info_id == account_tax_info_history.account_tax_info_id assert result.account_id == account_tax_info_history.account_id assert result.is_vat_exempt == account_tax_info_history.is_vat_exempt assert result.is_tax_treaty_claimed == \ account_tax_info_history.is_tax_treaty_claimed assert result.wht_rate_override is None def test_create_account_tax_info_history_on_trigger(): """Test to create an account_tax_info_history entry. An actual entry is created via database trigger on account_tax_info update. """ assert len(AccountTaxInfoHistory.query.all()) == 0 account_tax_info = AccountTaxInfoFactory.create() account_tax_info.update_attributes(country_of_tax_residence='GBR') account_tax_info.commit_changes() account_tax_info_history = AccountTaxInfoHistory.query.all() assert len(account_tax_info_history) == 1 assert account_tax_info_history[0].account_tax_info_id == \ account_tax_info.account_tax_info_id