-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_unit_overall.py
More file actions
107 lines (78 loc) · 3.57 KB
/
Copy pathtest_unit_overall.py
File metadata and controls
107 lines (78 loc) · 3.57 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
"""
Test Unit Overall Tests
Real unit tests for core GNN utilities and helper functions.
Tests real implementations.
"""
import sys
from pathlib import Path
# Add src to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
class TestPathUtilities:
"""Unit tests for path handling utilities."""
def test_project_root_detection(self) -> None:
"""Test that project root can be determined."""
from pathlib import Path
# The test file should be within the project structure
test_path = Path(__file__)
# Navigate up to find project root (contains pyproject.toml)
current = test_path.parent
found_root = False
for _ in range(5): # Don't go too far up
if (current / "pyproject.toml").exists():
found_root = True
break
current = current.parent
assert found_root, "Should find project root with pyproject.toml"
def test_src_directory_exists(self) -> None:
"""Test that src directory exists and contains modules."""
from pathlib import Path
src_dir = Path(__file__).parent.parent
assert src_dir.exists(), "src directory should exist"
assert (src_dir / "__init__.py").exists(), "src should have __init__.py"
class TestModuleStructure:
"""Unit tests for module structure validation."""
def test_gnn_module_exports(self) -> None:
"""Test that gnn module exports expected functions."""
import gnn
assert hasattr(gnn, "parse_gnn_file"), "gnn should export parse_gnn_file"
assert hasattr(gnn, "validate_gnn_structure"), (
"gnn should export validate_gnn_structure"
)
assert hasattr(gnn, "__version__"), "gnn should have __version__"
def test_export_module_exports(self) -> None:
"""Test that export module exports expected functions."""
import export
assert hasattr(export, "get_supported_formats"), (
"export should export get_supported_formats"
)
assert hasattr(export, "__version__"), "export should have __version__"
def test_render_module_exports(self) -> None:
"""Test that render module exports expected functions."""
import render
assert hasattr(render, "process_render"), "render should export process_render"
assert hasattr(render, "get_available_renderers"), (
"render should export get_available_renderers"
)
class TestFeatureFlags:
"""Unit tests for feature flag consistency."""
def test_gnn_features_dict(self) -> None:
"""Test GNN module has FEATURES dict."""
import gnn
assert hasattr(gnn, "FEATURES"), "gnn should have FEATURES"
assert isinstance(gnn.FEATURES, dict), "FEATURES should be a dict"
assert len(gnn.FEATURES) > 0, "FEATURES should not be empty"
def test_render_features_dict(self) -> None:
"""Test render module has FEATURES dict."""
import render
assert hasattr(render, "FEATURES"), "render should have FEATURES"
assert isinstance(render.FEATURES, dict), "FEATURES should be a dict"
def test_src_package_version(self) -> None:
"""Test installed package version matches expected format."""
from importlib.metadata import version
package_version = version("generalized-notation-notation")
# Version should be in semver-like format
parts = package_version.split(".")
assert len(parts) >= 2, (
f"Version '{package_version}' should have at least major.minor"
)