Skip to content

Commit d5d54ad

Browse files
committed
cloudflare test 4
1 parent 4f2de30 commit d5d54ad

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ __pycache__
1515
**/.pytest_cache
1616
**/.ruff_cache
1717
docker-compose.override.yml
18-
docker-compose.yml
18+
docker-compose.yml
19+
infrahub_demo.egg-info

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
15
[project]
26
authors = [
37
{name = "Tomek Zajac", email = "tomek@mastuazi.com"},
@@ -20,6 +24,9 @@ version = "0.1.5"
2024
description = "Design driven automation with Infrahub"
2125
readme = "README.md"
2226

27+
[tool.setuptools]
28+
packages = []
29+
2330
[tool.mypy]
2431
pretty = true
2532
ignore_missing_imports = true

tests/integration/test_workflow.py

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportAttributeAccessIssue=false
12
"""Integration test for the DC-2 demo workflow.
23
34
This test validates the complete workflow from the README:
@@ -9,10 +10,14 @@
910
6. Run DC generator
1011
7. Create proposed change
1112
8. 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

1418
import logging
1519
import time
20+
from pathlib import Path
1621

1722
import pytest
1823
from 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

tests/unit/test_j2_transforms.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,3 @@ infrahub_tests:
1313
spec:
1414
kind: "jinja2-transform-unit-render"
1515
directory: simulators
16-
# - resource: Jinja2Transform
17-
# resource_name: topology_clab
18-
# tests:
19-
# - name: syntax_check
20-
# spec:
21-
# kind: jinja2-transform-smoke
22-
# - name: baseline
23-
# expect: PASS
24-
# spec:
25-
# kind: "jinja2-transform-unit-render"
26-
# directory: tests/simulatorsy

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)