-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_integration_overall.py
More file actions
80 lines (64 loc) · 2.58 KB
/
test_integration_overall.py
File metadata and controls
80 lines (64 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import json
import pytest
from integration.processor import process_integration
class TestIntegrationOverall:
"""Test suite for Integration module."""
@pytest.fixture
def integration_files(self, safe_filesystem):
"""Create a set of files with dependencies."""
# File 1: Defines ComponentA
safe_filesystem.create_file("comp_a.md", """
# Component A
- name: ComponentA
type: Object
""")
# File 2: References ComponentA
safe_filesystem.create_file("comp_b.md", """
# Component B
- name: ComponentB
type: ComponentA
refs: $ref:ComponentA
""")
return safe_filesystem.temp_dir
def test_process_integration_flow(self, safe_filesystem, integration_files):
"""Test the integration processing workflow."""
target_dir = integration_files
output_dir = safe_filesystem.create_dir("integration_output")
success = process_integration(target_dir, output_dir, verbose=True)
assert success is True
# Check output
results_file = output_dir / "integration_results/integration_results.json"
assert results_file.exists()
with open(results_file, 'r') as f:
data = json.load(f)
assert data["success"] is True
assert data["processed_files"] == 2
# Check if dependency was found (if using networkx)
# We can't guarantee networkx is installed in checking env,
# but the processor handles missing networkx gracefully.
# If stats are present:
if "system_graph_stats" in data and data["system_graph_stats"]:
# Should have 2 nodes (ComponentA, ComponentB)
# And 1 edge (B -> A) or similar depending on implementation
pass
def test_process_integration_circular_dependency(self, safe_filesystem):
"""Test with circular dependency if networkx available."""
# A -> B, B -> A
safe_filesystem.create_file("cycle_a.md", """
- name: A
type: B
""")
safe_filesystem.create_file("cycle_b.md", """
- name: B
type: A
""")
output_dir = safe_filesystem.create_dir("output")
# This shouldn't crash, but might report issues
process_integration(safe_filesystem.temp_dir, output_dir)
results_file = output_dir / "integration_results/integration_results.json"
with open(results_file, 'r') as f:
data = json.load(f)
# If networkx is present, it might list issues.
# We assume success=True for the process itself (analysis completed),
# even if it found issues in the model.
assert data["success"] is True