Skip to content

Commit 1b43a38

Browse files
Copilot0xrinegade
andcommitted
Fix unit tests: correct URL validation errors, mock paths, and ValidationError params
Co-authored-by: 0xrinegade <[email protected]>
1 parent 21ab620 commit 1b43a38

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

python/tests/unit/test_additional_coverage_boost.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ def test_agent_registry_entry_edge_cases(self):
169169

170170
def test_service_endpoint_edge_cases(self):
171171
"""Test ServiceEndpoint with different protocols."""
172-
# Test explicit protocol setting
172+
# Test explicit protocol setting with valid URL
173173
endpoint = ServiceEndpoint(
174-
url="custom://example.com", protocol="custom", auth_type="bearer"
174+
url="https://example.com", protocol="custom", auth_type="bearer"
175175
)
176176
assert endpoint.protocol == "custom"
177177
assert endpoint.auth_type == "bearer"
@@ -222,7 +222,7 @@ def test_client_with_custom_commitment(self, mock_async_client):
222222
class TestAgentRegistryAdditionalCoverage:
223223
"""Additional tests for agent registry functionality."""
224224

225-
@patch("solana_ai_registries.agent.AsyncClient")
225+
@patch("solana_ai_registries.client.AsyncClient")
226226
def test_agent_registry_initialization(self, mock_async_client):
227227
"""Test AgentRegistry initialization."""
228228
mock_client = Mock()
@@ -233,7 +233,7 @@ def test_agent_registry_initialization(self, mock_async_client):
233233
class TestMcpServerRegistryAdditionalCoverage:
234234
"""Additional tests for MCP server registry functionality."""
235235

236-
@patch("solana_ai_registries.mcp.AsyncClient")
236+
@patch("solana_ai_registries.client.AsyncClient")
237237
def test_mcp_registry_initialization(self, mock_async_client):
238238
"""Test McpServerRegistry initialization."""
239239
mock_client = Mock()
@@ -244,7 +244,7 @@ def test_mcp_registry_initialization(self, mock_async_client):
244244
class TestPaymentManagerAdditionalCoverage:
245245
"""Additional tests for payment manager functionality."""
246246

247-
@patch("solana_ai_registries.payments.AsyncClient")
247+
@patch("solana_ai_registries.client.AsyncClient")
248248
def test_payment_manager_initialization(self, mock_async_client):
249249
"""Test PaymentManager initialization."""
250250
mock_client = Mock()
@@ -313,7 +313,7 @@ def test_all_validation_scenarios(self):
313313
# String length validation
314314
validate_string_length("short", 10, "test")
315315

316-
with pytest.raises(ValueError, match="test must be at most"):
316+
with pytest.raises(ValueError, match="test exceeds maximum length"):
317317
validate_string_length("very_long_string_that_exceeds_limit", 5, "test")
318318

319319
# URL validation
@@ -335,7 +335,7 @@ def test_all_validation_scenarios(self):
335335
]
336336

337337
for url in invalid_urls:
338-
with pytest.raises(ValueError, match="must be a valid URL"):
338+
with pytest.raises(ValueError, match="must start with one of"):
339339
validate_url(url, "test_url")
340340

341341
# Invalid schemes

python/tests/unit/test_coverage_booster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def test_validation_functions(self):
3939
validate_url("http://example.com", "test_url")
4040

4141
# Invalid cases
42-
with pytest.raises(ValueError, match="test_field must be at most"):
42+
with pytest.raises(ValueError, match="test_field exceeds maximum length"):
4343
validate_string_length("too_long_string", 5, "test_field")
4444

45-
with pytest.raises(ValueError, match="test_url must be a valid URL"):
45+
with pytest.raises(ValueError, match="test_url must start with one of"):
4646
validate_url("not_a_url", "test_url")
4747

4848
with pytest.raises(ValueError, match="test_url must start with one of"):
@@ -97,7 +97,7 @@ def test_exception_hierarchy(self):
9797
assert agent_error.owner == "owner123"
9898

9999
validation_error = ValidationError(
100-
"test_field", "test_constraint", "test_value"
100+
"test_field", "test_value", "test_constraint"
101101
)
102102
assert validation_error.field == "test_field"
103103
assert validation_error.constraint == "test_constraint"

0 commit comments

Comments
 (0)