11"""Test suite for data types and structures."""
22
33import pytest
4+
45from solana_ai_registries .types import (
56 AgentRegistryEntry ,
67 AgentSkill ,
@@ -56,18 +57,15 @@ def test_valid_endpoint(self) -> None:
5657 endpoint = ServiceEndpoint (
5758 protocol = "https" ,
5859 url = "https://api.example.com/v1" ,
59- description = "Test API endpoint"
60+ description = "Test API endpoint" ,
6061 )
6162 assert endpoint .protocol == "https"
6263 assert endpoint .url == "https://api.example.com/v1"
6364 assert endpoint .description == "Test API endpoint"
6465
6566 def test_endpoint_without_description (self ) -> None :
6667 """Test creating endpoint without description."""
67- endpoint = ServiceEndpoint (
68- protocol = "grpc" ,
69- url = "https://grpc.example.com:443"
70- )
68+ endpoint = ServiceEndpoint (protocol = "grpc" , url = "https://grpc.example.com:443" )
7169 assert endpoint .protocol == "grpc"
7270 assert endpoint .url == "https://grpc.example.com:443"
7371 assert endpoint .description is None
@@ -76,27 +74,22 @@ def test_protocol_too_long(self) -> None:
7674 """Test protocol validation - too long."""
7775 with pytest .raises (ValueError ) as exc_info :
7876 ServiceEndpoint (
79- protocol = "x" * 65 , # Over 64 chars
80- url = "https://api.example.com"
77+ protocol = "x" * 65 , url = "https://api.example.com" # Over 64 chars
8178 )
8279 assert "protocol exceeds maximum length" in str (exc_info .value )
8380
8481 def test_url_too_long (self ) -> None :
8582 """Test URL validation - too long."""
8683 with pytest .raises (ValueError ) as exc_info :
8784 ServiceEndpoint (
88- protocol = "https" ,
89- url = "https://" + "x" * 250 + ".com" # Over 256 chars
85+ protocol = "https" , url = "https://" + "x" * 250 + ".com" # Over 256 chars
9086 )
9187 assert "endpoint URL exceeds maximum length" in str (exc_info .value )
9288
9389 def test_invalid_url (self ) -> None :
9490 """Test URL validation - invalid format."""
9591 with pytest .raises (ValueError ) as exc_info :
96- ServiceEndpoint (
97- protocol = "https" ,
98- url = "not-a-valid-url"
99- )
92+ ServiceEndpoint (protocol = "https" , url = "not-a-valid-url" )
10093 assert "endpoint URL must start with one of" in str (exc_info .value )
10194
10295 def test_description_too_long (self ) -> None :
@@ -105,7 +98,7 @@ def test_description_too_long(self) -> None:
10598 ServiceEndpoint (
10699 protocol = "https" ,
107100 url = "https://api.example.com" ,
108- description = "x" * 513 # Over 512 chars
101+ description = "x" * 513 , # Over 512 chars
109102 )
110103 assert "endpoint description exceeds maximum length" in str (exc_info .value )
111104
@@ -119,7 +112,7 @@ def test_valid_skill(self) -> None:
119112 skill_id = "trading" ,
120113 name = "Trading Agent" ,
121114 tags = ["finance" , "crypto" ],
122- metadata = {"model" : "gpt-4" }
115+ metadata = {"model" : "gpt-4" },
123116 )
124117 assert skill .skill_id == "trading"
125118 assert skill .name == "Trading Agent"
@@ -128,10 +121,7 @@ def test_valid_skill(self) -> None:
128121
129122 def test_skill_without_optional_fields (self ) -> None :
130123 """Test creating skill without optional fields."""
131- skill = AgentSkill (
132- skill_id = "analysis" ,
133- name = "Data Analysis"
134- )
124+ skill = AgentSkill (skill_id = "analysis" , name = "Data Analysis" )
135125 assert skill .skill_id == "analysis"
136126 assert skill .name == "Data Analysis"
137127 assert skill .tags == []
@@ -140,19 +130,13 @@ def test_skill_without_optional_fields(self) -> None:
140130 def test_skill_id_too_long (self ) -> None :
141131 """Test skill ID validation - too long."""
142132 with pytest .raises (ValueError ) as exc_info :
143- AgentSkill (
144- skill_id = "x" * 65 , # Over 64 chars
145- name = "Test Skill"
146- )
133+ AgentSkill (skill_id = "x" * 65 , name = "Test Skill" ) # Over 64 chars
147134 assert "skill ID exceeds maximum length" in str (exc_info .value )
148135
149136 def test_skill_name_too_long (self ) -> None :
150137 """Test skill name validation - too long."""
151138 with pytest .raises (ValueError ) as exc_info :
152- AgentSkill (
153- skill_id = "test" ,
154- name = "x" * 129 # Over 128 chars
155- )
139+ AgentSkill (skill_id = "test" , name = "x" * 129 ) # Over 128 chars
156140 assert "skill name exceeds maximum length" in str (exc_info .value )
157141
158142 def test_too_many_tags (self ) -> None :
@@ -161,17 +145,15 @@ def test_too_many_tags(self) -> None:
161145 AgentSkill (
162146 skill_id = "test" ,
163147 name = "Test Skill" ,
164- tags = ["tag1" , "tag2" , "tag3" , "tag4" , "tag5" , "tag6" ] # Over 5 tags
148+ tags = ["tag1" , "tag2" , "tag3" , "tag4" , "tag5" , "tag6" ], # Over 5 tags
165149 )
166150 assert "Maximum 5 tags allowed per skill" in str (exc_info .value )
167151
168152 def test_tag_too_long (self ) -> None :
169153 """Test individual tag validation - too long."""
170154 with pytest .raises (ValueError ) as exc_info :
171155 AgentSkill (
172- skill_id = "test" ,
173- name = "Test Skill" ,
174- tags = ["x" * 33 ] # Over 32 chars
156+ skill_id = "test" , name = "Test Skill" , tags = ["x" * 33 ] # Over 32 chars
175157 )
176158 assert "skill tag exceeds maximum length" in str (exc_info .value )
177159
@@ -187,7 +169,7 @@ def test_minimal_valid_agent(self) -> None:
187169 description = "A test agent for validation" ,
188170 agent_version = "1.0.0" ,
189171 owner = "owner_pubkey_string" ,
190- status = AgentStatus .ACTIVE
172+ status = AgentStatus .ACTIVE ,
191173 )
192174 assert agent .agent_id == "test_agent"
193175 assert agent .name == "Test Agent"
@@ -203,7 +185,7 @@ def test_full_agent(self) -> None:
203185 """Test creating a fully populated agent."""
204186 endpoint = ServiceEndpoint ("https" , "https://api.example.com" )
205187 skill = AgentSkill ("trading" , "Trading Skill" )
206-
188+
207189 agent = AgentRegistryEntry (
208190 agent_id = "full_agent" ,
209191 name = "Full Agent" ,
@@ -235,7 +217,7 @@ def test_agent_id_too_long(self) -> None:
235217 description = "Test description" ,
236218 agent_version = "1.0.0" ,
237219 owner = "owner" ,
238- status = AgentStatus .ACTIVE
220+ status = AgentStatus .ACTIVE ,
239221 )
240222 assert "agent_id exceeds maximum length" in str (exc_info .value )
241223
@@ -248,7 +230,7 @@ def test_agent_name_too_long(self) -> None:
248230 description = "Test description" ,
249231 agent_version = "1.0.0" ,
250232 owner = "owner" ,
251- status = AgentStatus .ACTIVE
233+ status = AgentStatus .ACTIVE ,
252234 )
253235 assert "name exceeds maximum length" in str (exc_info .value )
254236
@@ -258,7 +240,9 @@ def test_too_many_endpoints(self) -> None:
258240 ServiceEndpoint ("https" , "https://api1.example.com" ),
259241 ServiceEndpoint ("grpc" , "https://api2.example.com" ),
260242 ServiceEndpoint ("ws" , "https://api3.example.com" ),
261- ServiceEndpoint ("tcp" , "https://api4.example.com" ), # 4th endpoint - over limit
243+ ServiceEndpoint (
244+ "tcp" , "https://api4.example.com"
245+ ), # 4th endpoint - over limit
262246 ]
263247 with pytest .raises (ValueError ) as exc_info :
264248 AgentRegistryEntry (
@@ -268,13 +252,15 @@ def test_too_many_endpoints(self) -> None:
268252 agent_version = "1.0.0" ,
269253 owner = "owner" ,
270254 status = AgentStatus .ACTIVE ,
271- service_endpoints = endpoints
255+ service_endpoints = endpoints ,
272256 )
273257 assert "Maximum 3 service endpoints allowed" in str (exc_info .value )
274258
275259 def test_too_many_skills (self ) -> None :
276260 """Test skills validation - too many."""
277- skills = [AgentSkill (f"skill_{ i } " , f"Skill { i } " ) for i in range (11 )] # 11 skills - over limit
261+ skills = [
262+ AgentSkill (f"skill_{ i } " , f"Skill { i } " ) for i in range (11 )
263+ ] # 11 skills - over limit
278264 with pytest .raises (ValueError ) as exc_info :
279265 AgentRegistryEntry (
280266 agent_id = "test" ,
@@ -283,7 +269,7 @@ def test_too_many_skills(self) -> None:
283269 agent_version = "1.0.0" ,
284270 owner = "owner" ,
285271 status = AgentStatus .ACTIVE ,
286- skills = skills
272+ skills = skills ,
287273 )
288274 assert "Maximum 10 skills allowed" in str (exc_info .value )
289275
@@ -298,7 +284,7 @@ def test_too_many_tags(self) -> None:
298284 agent_version = "1.0.0" ,
299285 owner = "owner" ,
300286 status = AgentStatus .ACTIVE ,
301- tags = tags
287+ tags = tags ,
302288 )
303289 assert "Maximum 10 tags allowed" in str (exc_info .value )
304290
@@ -312,7 +298,7 @@ def test_tag_too_long(self) -> None:
312298 agent_version = "1.0.0" ,
313299 owner = "owner" ,
314300 status = AgentStatus .ACTIVE ,
315- tags = ["x" * 33 ] # Over 32 chars
301+ tags = ["x" * 33 ], # Over 32 chars
316302 )
317303 assert "agent tag exceeds maximum length" in str (exc_info .value )
318304
@@ -345,7 +331,7 @@ def test_minimal_valid_server(self) -> None:
345331 server_version = "1.0.0" ,
346332 endpoint_url = "https://server.example.com" ,
347333 owner = "owner_pubkey" ,
348- status = McpServerStatus .ACTIVE
334+ status = McpServerStatus .ACTIVE ,
349335 )
350336 assert server .server_id == "test_server"
351337 assert server .name == "Test Server"
@@ -363,7 +349,7 @@ def test_server_id_too_long(self) -> None:
363349 server_version = "1.0.0" ,
364350 endpoint_url = "https://server.example.com" ,
365351 owner = "owner" ,
366- status = McpServerStatus .ACTIVE
352+ status = McpServerStatus .ACTIVE ,
367353 )
368354 assert "server_id exceeds maximum length" in str (exc_info .value )
369355
@@ -376,7 +362,7 @@ def test_server_name_too_long(self) -> None:
376362 server_version = "1.0.0" ,
377363 endpoint_url = "https://server.example.com" ,
378364 owner = "owner" ,
379- status = McpServerStatus .ACTIVE
365+ status = McpServerStatus .ACTIVE ,
380366 )
381367 assert "name exceeds maximum length" in str (exc_info .value )
382368
@@ -389,7 +375,7 @@ def test_invalid_endpoint_url(self) -> None:
389375 server_version = "1.0.0" ,
390376 endpoint_url = "not-a-valid-url" ,
391377 owner = "owner" ,
392- status = McpServerStatus .ACTIVE
378+ status = McpServerStatus .ACTIVE ,
393379 )
394380 assert "endpoint_url must start with one of" in str (exc_info .value )
395381
@@ -429,7 +415,7 @@ def test_full_tool(self) -> None:
429415 description = "Basic math operations" ,
430416 tags = ["math" , "calc" ],
431417 input_schema = '{"type": "object"}' ,
432- output_schema = '{"type": "number"}'
418+ output_schema = '{"type": "number"}' ,
433419 )
434420 assert tool .name == "calculator"
435421 assert tool .description == "Basic math operations"
@@ -473,7 +459,7 @@ def test_full_resource(self) -> None:
473459 uri_pattern = "http://api.example.com/*" ,
474460 name = "API Resources" ,
475461 description = "External API endpoints" ,
476- tags = ["api" , "http" ]
462+ tags = ["api" , "http" ],
477463 )
478464 assert resource .uri_pattern == "http://api.example.com/*"
479465 assert resource .name == "API Resources"
@@ -491,7 +477,7 @@ def test_too_many_tags(self) -> None:
491477 with pytest .raises (ValueError ) as exc_info :
492478 McpResource (
493479 uri_pattern = "test://*" ,
494- tags = ["tag1" , "tag2" , "tag3" , "tag4" ] # Over 3 tags
480+ tags = ["tag1" , "tag2" , "tag3" , "tag4" ], # Over 3 tags
495481 )
496482 assert "Maximum 3 tags allowed per resource" in str (exc_info .value )
497483
@@ -517,7 +503,7 @@ def test_full_prompt(self) -> None:
517503 prompt = McpPrompt (
518504 name = "code_review" ,
519505 description = "Code review assistant" ,
520- tags = ["code" , "review" ]
506+ tags = ["code" , "review" ],
521507 )
522508 assert prompt .name == "code_review"
523509 assert prompt .description == "Code review assistant"
@@ -563,7 +549,7 @@ def test_full_capabilities(self) -> None:
563549 tool = McpTool (name = "test_tool" )
564550 resource = McpResource (uri_pattern = "test://*" )
565551 prompt = McpPrompt (name = "test_prompt" )
566-
552+
567553 caps = McpCapabilities (
568554 supports_tools = True ,
569555 supports_resources = True ,
@@ -573,7 +559,7 @@ def test_full_capabilities(self) -> None:
573559 prompt_count = 1 ,
574560 tools = [tool ],
575561 resources = [resource ],
576- prompts = [prompt ]
562+ prompts = [prompt ],
577563 )
578564 assert caps .supports_tools is True
579565 assert caps .supports_resources is True
@@ -583,4 +569,4 @@ def test_full_capabilities(self) -> None:
583569 assert caps .prompt_count == 1
584570 assert len (caps .tools ) == 1
585571 assert len (caps .resources ) == 1
586- assert len (caps .prompts ) == 1
572+ assert len (caps .prompts ) == 1
0 commit comments