"""Test Reference Tax Withholding handlers.""" from unittest.mock import call, patch @patch('payment.blueprints.reference_tax_withholding.logic') def test_get_reference_tax_withholding(mock_logic, fixture_client): """Test get_reference_tax_withholding request.""" mock_tax_withholding = [ { 'country_of_withholding': 'GBR', 'country_of_tax_residence': 'CHL', 'tax_rate': '10.00', } ] mock_response = { 'items': mock_tax_withholding, 'total_count': len(mock_tax_withholding), } mock_logic.get_reference_tax_withholding.return_value = mock_response res = fixture_client.get('/reference-tax-withholding') assert res.status_code == 200 assert res.json == mock_response mock_logic.get_reference_tax_withholding.assert_called_once() @patch('payment.blueprints.reference_tax_withholding.logic') def test_get_reference_tax_withholding_with_filter(mock_logic, fixture_client): """Test get_reference_tax_withholding request with filter.""" mock_tax_withholding = [ { 'country_of_withholding': 'GBR', 'country_of_tax_residence': 'CHL', 'tax_rate': '10.00', } ] mock_response = { 'items': mock_tax_withholding, 'total_count': len(mock_tax_withholding), } mock_logic.get_reference_tax_withholding.return_value = mock_response res = fixture_client.get( '/reference-tax-withholding' '?country_of_withholding=GBR&country_of_tax_residence=CHL' ) assert res.status_code == 200 assert res.json == mock_response assert mock_logic.get_reference_tax_withholding.call_args_list == [ call(country_of_withholding='GBR', country_of_tax_residence='CHL') ]