1+ # pyright: reportAttributeAccessIssue=false
12"""Integration test for the DC-2 demo workflow.
23
34This test validates the complete workflow from the README:
9106. Run DC generator
10117. Create proposed change
11128. Validate and merge
13+
14+ Note: Pylance warnings about .value attributes are suppressed at file level.
15+ The Infrahub SDK uses dynamic attribute generation at runtime.
1216"""
1317
1418import logging
1519import time
20+ from pathlib import Path
1621
1722import pytest
1823from infrahub_sdk import InfrahubClient , InfrahubClientSync
@@ -48,9 +53,9 @@ def test_01_schema_load(self, client_main: InfrahubClientSync) -> None:
4853 logging .info ("Schema load stderr: %s" , load_schemas .stderr )
4954
5055 # Check that schemas loaded successfully (even if returncode is non-zero due to warnings)
51- assert "loaded successfully" in load_schemas . stdout or load_schemas . returncode == 0 , (
52- f"Schema load failed: { load_schemas .stdout } \n { load_schemas .stderr } "
53- )
56+ assert (
57+ "loaded successfully" in load_schemas .stdout or load_schemas .returncode == 0
58+ ), f"Schema load failed: { load_schemas . stdout } \n { load_schemas . stderr } "
5459
5560 def test_02_load_menu (self , client_main : InfrahubClientSync ) -> None :
5661 """Load menu definitions."""
@@ -102,11 +107,10 @@ async def test_05_add_repository(
102107
103108 client = async_client_main
104109 src_directory = PROJECT_DIRECTORY
105-
106110 git_repository = GitRepo (
107111 name = "demo_repo" ,
108112 src_directory = src_directory ,
109- dst_directory = remote_repos_dir ,
113+ dst_directory = Path ( remote_repos_dir ) ,
110114 )
111115
112116 response = await git_repository .add_to_infrahub (client = client )
@@ -147,9 +151,13 @@ async def test_05_add_repository(
147151 )
148152 logging .info ("Repository synchronized successfully" )
149153
150- def test_06_create_branch (self , client_main : InfrahubClientSync , default_branch : str ) -> None :
154+ def test_06_create_branch (
155+ self , client_main : InfrahubClientSync , default_branch : str
156+ ) -> None :
151157 """Create a new branch for the DC-2 deployment."""
152- logging .info ("Starting test: test_06_create_branch - branch: %s" , default_branch )
158+ logging .info (
159+ "Starting test: test_06_create_branch - branch: %s" , default_branch
160+ )
153161
154162 # Check if branch already exists
155163 existing_branches = client_main .branch .all ()
@@ -159,7 +167,9 @@ def test_06_create_branch(self, client_main: InfrahubClientSync, default_branch:
159167 client_main .branch .create (default_branch )
160168 logging .info ("Created branch: %s" , default_branch )
161169
162- def test_07_load_dc2_design (self , client_main : InfrahubClientSync , default_branch : str ) -> None :
170+ def test_07_load_dc2_design (
171+ self , client_main : InfrahubClientSync , default_branch : str
172+ ) -> None :
163173 """Load DC-2 design data onto the branch."""
164174 logging .info ("Starting test: test_07_load_dc2_design" )
165175
@@ -236,7 +246,9 @@ async def test_09_run_generator(
236246 time .sleep (10 )
237247
238248 if not definition :
239- pytest .skip ("Generator definition 'create_dc' not available - skipping generator test" )
249+ pytest .skip (
250+ "Generator definition 'create_dc' not available - skipping generator test"
251+ )
240252
241253 logging .info ("Found generator: %s" , definition .name .value )
242254
@@ -262,7 +274,7 @@ async def test_09_run_generator(
262274 logging .info ("Generator task started: %s" , task_id )
263275
264276 # Wait for generator to complete (can take a while for DC generation)
265- task = client .task .wait_for_completion (id = task_id , timeout = 1800 )
277+ task = await client .task .wait_for_completion (id = task_id , timeout = 1800 )
266278
267279 assert task .state == TaskState .COMPLETED , (
268280 f"Task { task .id } - generator create_dc did not complete successfully. "
@@ -283,15 +295,19 @@ async def test_10_verify_devices_created(
283295 devices = await client .all (kind = "DcimGenericDevice" )
284296
285297 if not devices :
286- pytest .skip ("No devices found - generator may not have run (test_09 may have been skipped)" )
298+ pytest .skip (
299+ "No devices found - generator may not have run (test_09 may have been skipped)"
300+ )
287301
288302 logging .info ("Found %d devices after generator run" , len (devices ))
289303
290304 # Check for specific device types (spine, leaf, etc.)
291305 device_names = [device .name .value for device in devices ]
292306 logging .info ("Created devices: %s" , ", " .join (device_names ))
293307
294- def test_11_create_diff (self , client_main : InfrahubClientSync , default_branch : str ) -> None :
308+ def test_11_create_diff (
309+ self , client_main : InfrahubClientSync , default_branch : str
310+ ) -> None :
295311 """Create a diff for the branch."""
296312 logging .info ("Starting test: test_11_create_diff" )
297313
@@ -392,7 +408,11 @@ def test_12_create_proposed_change(
392408 if failed_validations :
393409 for result in failed_validations :
394410 name = result .name .value if hasattr (result , "name" ) else str (result .id )
395- conclusion = result .conclusion .value if hasattr (result , "conclusion" ) else "unknown"
411+ conclusion = (
412+ result .conclusion .value
413+ if hasattr (result , "conclusion" )
414+ else "unknown"
415+ )
396416 logging .error (
397417 "Validation failed: %s - %s" ,
398418 name ,
@@ -404,10 +424,10 @@ def test_12_create_proposed_change(
404424 logging .info ("Validations completed. Results:" )
405425 for result in validation_results :
406426 name = result .name .value if hasattr (result , "name" ) else str (result .id )
407- conclusion = result .conclusion .value if hasattr (result , "conclusion" ) else "unknown"
408- logging .info (
409- " - %s: %s" , name , conclusion
427+ conclusion = (
428+ result .conclusion .value if hasattr (result , "conclusion" ) else "unknown"
410429 )
430+ logging .info (" - %s: %s" , name , conclusion )
411431
412432 def test_13_merge_proposed_change (
413433 self , client_main : InfrahubClientSync , default_branch : str
@@ -444,7 +464,9 @@ def test_13_merge_proposed_change(
444464 )
445465 logging .info ("Proposed change merged successfully" )
446466
447- async def test_14_verify_merge_to_main (self , async_client_main : InfrahubClient ) -> None :
467+ async def test_14_verify_merge_to_main (
468+ self , async_client_main : InfrahubClient
469+ ) -> None :
448470 """Verify that DC-2 and devices exist in main branch."""
449471 logging .info ("Starting test: test_14_verify_merge_to_main" )
450472
0 commit comments