"""Tests payment hold serialization.""" import datetime from abacus_common_logic.utils.dates import safe_format_date from abacus_account.schemas import PaymentHoldSchema def test_payment_hold_schema(): """Tests payment hold schema.""" mock_payment_hold_info = { 'payment_hold_id': 1, 'account_id': 1, 'is_on_hold': 1, 'start_date': datetime.date(2020, 4, 24), 'reason': 'Account was rude to me.', 'created_at': datetime.datetime.now(), 'created_by': 'test_user', 'last_modified': datetime.datetime.now(), 'last_modified_by': 'test_user', } result = PaymentHoldSchema().dump(mock_payment_hold_info) assert result['payment_hold_id'] == mock_payment_hold_info['payment_hold_id'] assert result['account_id'] == mock_payment_hold_info['account_id'] assert result['is_on_hold'] == mock_payment_hold_info['is_on_hold'] assert result['start_date'] == safe_format_date( mock_payment_hold_info['start_date'] ) assert result['reason'] == mock_payment_hold_info['reason'] assert result['created_at'] == mock_payment_hold_info['created_at'].strftime( '%Y-%m-%d' ) assert result['created_by'] == mock_payment_hold_info['created_by'] assert result['last_modified'] == mock_payment_hold_info['last_modified'].strftime( '%Y-%m-%d' ) assert result['last_modified_by'] == mock_payment_hold_info['last_modified_by']