77import pytest
88
99from infrahub_sdk .node import InfrahubNode , InfrahubNodeSync
10- from infrahub_sdk .schema import NodeSchema
10+ from infrahub_sdk .schema import NodeSchema , NodeSchemaAPI
1111
1212if TYPE_CHECKING :
1313 from infrahub_sdk import InfrahubClient , InfrahubClientSync
1616
1717
1818@pytest .fixture
19- async def hierarchical_schema ():
19+ async def hierarchical_schema () -> NodeSchemaAPI :
2020 """Schema for a hierarchical location node with hierarchy support."""
2121 data = {
2222 "name" : "Location" ,
@@ -43,7 +43,7 @@ async def hierarchical_schema():
4343 },
4444 ],
4545 }
46- schema_api = NodeSchema (** data ).convert_api () # type: ignore
46+ schema_api = NodeSchema (** data ).convert_api ()
4747 # Set hierarchy field manually since it's not part of NodeSchema but only NodeSchemaAPI
4848 # This field would normally be set by the backend
4949 schema_api .hierarchy = "InfraLocation"
@@ -53,7 +53,7 @@ async def hierarchical_schema():
5353@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
5454async def test_hierarchical_node_has_hierarchy_support (
5555 client : InfrahubClient , client_sync : InfrahubClientSync , hierarchical_schema , client_type
56- ):
56+ ) -> None :
5757 """Test that hierarchical nodes are properly detected and support parent/children/ancestors/descendants."""
5858 if client_type == "standard" :
5959 node = InfrahubNode (client = client , schema = hierarchical_schema )
@@ -68,7 +68,7 @@ async def test_hierarchical_node_has_hierarchy_support(
6868@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
6969async def test_hierarchical_node_has_all_hierarchical_fields (
7070 client : InfrahubClient , client_sync : InfrahubClientSync , hierarchical_schema , client_type
71- ):
71+ ) -> None :
7272 """Test that hierarchical nodes have parent, children, ancestors and descendants attributes."""
7373 if client_type == "standard" :
7474 node = InfrahubNode (client = client , schema = hierarchical_schema )
@@ -111,7 +111,7 @@ async def test_hierarchical_node_has_all_hierarchical_fields(
111111@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
112112async def test_hierarchical_node_with_parent_data (
113113 client : InfrahubClient , client_sync : InfrahubClientSync , hierarchical_schema , client_type
114- ):
114+ ) -> None :
115115 """Test that hierarchical nodes can be initialized with parent data."""
116116 data = {
117117 "id" : "location-1" ,
@@ -134,7 +134,7 @@ async def test_hierarchical_node_with_parent_data(
134134@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
135135async def test_hierarchical_node_with_children_data (
136136 client : InfrahubClient , client_sync : InfrahubClientSync , hierarchical_schema , client_type
137- ):
137+ ) -> None :
138138 """Test that hierarchical nodes can be initialized with children data."""
139139 data = {
140140 "id" : "location-1" ,
@@ -165,7 +165,7 @@ async def test_hierarchical_node_with_children_data(
165165@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
166166async def test_hierarchical_node_with_ancestors_data (
167167 client : InfrahubClient , client_sync : InfrahubClientSync , hierarchical_schema , client_type
168- ):
168+ ) -> None :
169169 """Test that hierarchical nodes can be initialized with ancestors data."""
170170 data = {
171171 "id" : "location-1" ,
@@ -196,7 +196,7 @@ async def test_hierarchical_node_with_ancestors_data(
196196@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
197197async def test_hierarchical_node_with_descendants_data (
198198 client : InfrahubClient , client_sync : InfrahubClientSync , hierarchical_schema , client_type
199- ):
199+ ) -> None :
200200 """Test that hierarchical nodes can be initialized with descendants data."""
201201 data = {
202202 "id" : "location-1" ,
@@ -230,7 +230,7 @@ async def test_hierarchical_node_with_descendants_data(
230230@pytest .mark .parametrize ("client_type" , ["standard" , "sync" ])
231231async def test_non_hierarchical_node_no_hierarchical_fields (
232232 client : InfrahubClient , client_sync : InfrahubClientSync , location_schema , client_type
233- ):
233+ ) -> None :
234234 """Test that non-hierarchical nodes don't have parent/children/ancestors/descendants."""
235235 if client_type == "standard" :
236236 node = InfrahubNode (client = client , schema = location_schema )
@@ -254,7 +254,7 @@ async def test_non_hierarchical_node_no_hierarchical_fields(
254254 _ = node .descendants
255255
256256
257- async def test_hierarchical_node_query_generation_includes_parent (client : InfrahubClient , hierarchical_schema ):
257+ async def test_hierarchical_node_query_generation_includes_parent (client : InfrahubClient , hierarchical_schema ) -> None :
258258 """Test that query generation includes parent when requested."""
259259 # Pre-populate schema cache to avoid fetching from server
260260 cache_data = {
@@ -276,7 +276,9 @@ async def test_hierarchical_node_query_generation_includes_parent(client: Infrah
276276 assert "...on InfraLocation" in query_data ["parent" ]["node" ]
277277
278278
279- async def test_hierarchical_node_query_generation_includes_children (client : InfrahubClient , hierarchical_schema ):
279+ async def test_hierarchical_node_query_generation_includes_children (
280+ client : InfrahubClient , hierarchical_schema
281+ ) -> None :
280282 """Test that query generation includes children when requested."""
281283 # Pre-populate schema cache to avoid fetching from server
282284 cache_data = {
@@ -299,7 +301,9 @@ async def test_hierarchical_node_query_generation_includes_children(client: Infr
299301 assert "...on InfraLocation" in query_data ["children" ]["edges" ]["node" ]
300302
301303
302- async def test_hierarchical_node_query_generation_includes_ancestors (client : InfrahubClient , hierarchical_schema ):
304+ async def test_hierarchical_node_query_generation_includes_ancestors (
305+ client : InfrahubClient , hierarchical_schema
306+ ) -> None :
303307 """Test that query generation includes ancestors when requested."""
304308 # Pre-populate schema cache to avoid fetching from server
305309 cache_data = {
@@ -322,7 +326,9 @@ async def test_hierarchical_node_query_generation_includes_ancestors(client: Inf
322326 assert "...on InfraLocation" in query_data ["ancestors" ]["edges" ]["node" ]
323327
324328
325- async def test_hierarchical_node_query_generation_includes_descendants (client : InfrahubClient , hierarchical_schema ):
329+ async def test_hierarchical_node_query_generation_includes_descendants (
330+ client : InfrahubClient , hierarchical_schema
331+ ) -> None :
326332 """Test that query generation includes descendants when requested."""
327333 # Pre-populate schema cache to avoid fetching from server
328334 cache_data = {
@@ -345,7 +351,9 @@ async def test_hierarchical_node_query_generation_includes_descendants(client: I
345351 assert "...on InfraLocation" in query_data ["descendants" ]["edges" ]["node" ]
346352
347353
348- async def test_hierarchical_node_query_generation_prefetch_relationships (client : InfrahubClient , hierarchical_schema ):
354+ async def test_hierarchical_node_query_generation_prefetch_relationships (
355+ client : InfrahubClient , hierarchical_schema
356+ ) -> None :
349357 """Test that query generation includes all hierarchical fields with prefetch_relationships=True."""
350358 # Pre-populate schema cache to avoid fetching from server
351359 cache_data = {
@@ -366,7 +374,7 @@ async def test_hierarchical_node_query_generation_prefetch_relationships(client:
366374 assert "descendants" in query_data
367375
368376
369- async def test_hierarchical_node_query_generation_exclude (client : InfrahubClient , hierarchical_schema ):
377+ async def test_hierarchical_node_query_generation_exclude (client : InfrahubClient , hierarchical_schema ) -> None :
370378 """Test that query generation respects exclude for hierarchical fields."""
371379 # Pre-populate schema cache to avoid fetching from server
372380 cache_data = {
@@ -387,7 +395,9 @@ async def test_hierarchical_node_query_generation_exclude(client: InfrahubClient
387395 assert "descendants" in query_data
388396
389397
390- def test_hierarchical_node_sync_query_generation_includes_parent (client_sync : InfrahubClientSync , hierarchical_schema ):
398+ def test_hierarchical_node_sync_query_generation_includes_parent (
399+ client_sync : InfrahubClientSync , hierarchical_schema
400+ ) -> None :
391401 """Test that sync query generation includes parent when requested."""
392402 # Set schema in cache to avoid HTTP request
393403 cache_data = {
@@ -411,7 +421,7 @@ def test_hierarchical_node_sync_query_generation_includes_parent(client_sync: In
411421
412422def test_hierarchical_node_sync_query_generation_includes_children (
413423 client_sync : InfrahubClientSync , hierarchical_schema
414- ):
424+ ) -> None :
415425 """Test that sync query generation includes children when requested."""
416426 # Set schema in cache to avoid HTTP request
417427 cache_data = {
@@ -436,7 +446,7 @@ def test_hierarchical_node_sync_query_generation_includes_children(
436446
437447def test_hierarchical_node_sync_query_generation_includes_ancestors (
438448 client_sync : InfrahubClientSync , hierarchical_schema
439- ):
449+ ) -> None :
440450 """Test that sync query generation includes ancestors when requested."""
441451 # Set schema in cache to avoid HTTP request
442452 cache_data = {
@@ -461,7 +471,7 @@ def test_hierarchical_node_sync_query_generation_includes_ancestors(
461471
462472def test_hierarchical_node_sync_query_generation_includes_descendants (
463473 client_sync : InfrahubClientSync , hierarchical_schema
464- ):
474+ ) -> None :
465475 """Test that sync query generation includes descendants when requested."""
466476 # Set schema in cache to avoid HTTP request
467477 cache_data = {
@@ -484,7 +494,9 @@ def test_hierarchical_node_sync_query_generation_includes_descendants(
484494 assert "...on InfraLocation" in query_data ["descendants" ]["edges" ]["node" ]
485495
486496
487- async def test_hierarchical_node_no_infinite_recursion_with_children (client : InfrahubClient , hierarchical_schema ):
497+ async def test_hierarchical_node_no_infinite_recursion_with_children (
498+ client : InfrahubClient , hierarchical_schema
499+ ) -> None :
488500 """Test that including children does not cause infinite recursion."""
489501 # Pre-populate schema cache to avoid fetching from server
490502 cache_data = {
@@ -510,7 +522,7 @@ async def test_hierarchical_node_no_infinite_recursion_with_children(client: Inf
510522
511523def test_hierarchical_node_sync_no_infinite_recursion_with_children (
512524 client_sync : InfrahubClientSync , hierarchical_schema
513- ):
525+ ) -> None :
514526 """Test that including children does not cause infinite recursion in sync mode."""
515527 # Set schema in cache to avoid HTTP request
516528 cache_data = {
0 commit comments