"""Test Payment Hold handlers.""" import datetime from unittest.mock import patch from owsresponse import response @patch('abacus_account.blueprints.payment_hold.logic') def test_create_payment_hold(mock_logic, fixture_client): """Test for the payment hold creation handler.""" post_data = { 'is_on_hold': True, 'reason': 'to teach them a lesson', 'start_date': '2099-05-01' } mock_response = response.Response(message='ok', status=201) mock_logic.create_or_update_payment_hold.return_value = mock_response res = fixture_client.post('/account/123/payment-hold', json=post_data) assert res.status_code == 201 mock_logic.create_or_update_payment_hold.assert_called_once_with( account_id=123, is_on_hold=True, reason='to teach them a lesson', start_date=datetime.date.fromisoformat('2099-05-01') ) @patch('abacus_account.blueprints.payment_hold.logic') def test_get_payment_hold(mock_logic, fixture_client): """Test for the payment hold fetching handler.""" mock_response = response.Response(message={'result': 'ok'}, status=200) mock_logic.get_payment_hold.return_value = mock_response res = fixture_client.get('/account/111/payment-hold') assert res.status_code == 200 mock_logic.get_payment_hold.assert_called_once_with(111)