"""Test Account Payee History logic.""" from unittest.mock import patch from abacus_account.logic import account_payee_history as logic from tests.utils.factories import ( AccountFactory, AccountPayeeFactory, AccountPayeeHistoryFactory ) @patch('abacus_account.logic.account_payee_history.models') def test_get_account_payee_history(mock_model): """Test to retrieve an account_payee_history for a given account.""" account = AccountFactory.create() account_payee = AccountPayeeFactory.create(account=account) account_payee_history = AccountPayeeHistoryFactory.create( account=account, account_payee_id=account_payee.account_payee_id ) mock_model.Account.get_by_id_or_error.return_value = account res = logic.get_account_payee_history(account.account_id) assert res.status == 200 message = res.message assert len(message) == 1 assert message[0]['account_payee_id'] == \ account_payee_history.account_payee_id