"""Test Account Payee History schemas.""" from abacus_common_logic.utils.dates import safe_format_date from abacus_account.schemas.account_payee_history import AccountPayeeHistorySchema from abacus_account.tests.utils.factories import ( AccountFactory, AccountPayeeFactory, AccountPayeeHistoryFactory, ReferencePayoneerProgramFactory, ) def test_account_payee_history_schema(fresh_db): """Test account_payee_history serialization.""" account = AccountFactory.create() account_payee = AccountPayeeFactory.create( account=account, reference_payoneer_program=ReferencePayoneerProgramFactory.create(), ) history = AccountPayeeHistoryFactory.create( account=account, account_payee_id=account_payee.account_payee_id, payoneer_program_id=account_payee.payoneer_program_id, ) res = AccountPayeeHistorySchema().dump(history) assert res['account_payee_history_id'] == history.account_payee_history_id assert res['account_id'] == history.account_id assert res['account_payee_id'] == history.account_payee_id assert res['payoneer_program_id'] == history.payoneer_program_id assert res['payoneer_payee_id'] == history.payoneer_payee_id assert res['payoneer_iframe_url'] == history.payoneer_iframe_url assert res['payoneer_iframe_url_date'] == safe_format_date( history.payoneer_iframe_url_date ) assert res['payoneer_session_id'] == history.payoneer_session_id assert res['created_at'] == safe_format_date(history.created_at) assert res['last_modified'] == safe_format_date(history.last_modified)