-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_environment_integration.py
More file actions
198 lines (150 loc) · 6.12 KB
/
test_environment_integration.py
File metadata and controls
198 lines (150 loc) · 6.12 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/env python3
"""
Test Environment Integration - Integration tests for environment setup.
Tests the integration between environment validation and pipeline components.
"""
import sys
from pathlib import Path
from typing import Any
import pytest
# Add src to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
class TestEnvironmentSetupIntegration:
"""Tests for environment setup integration with pipeline."""
@pytest.mark.integration
def test_environment_validates_before_pipeline(self) -> None:
"""Test environment validation runs before pipeline."""
from utils.test_utils import validate_test_environment
result = validate_test_environment()
# validate_test_environment returns (bool, list) tuple or bool
if isinstance(result, tuple):
assert result[0] is True
else:
assert result is True or result is None
@pytest.mark.integration
def test_environment_paths_accessible(self) -> None:
"""Test all required paths are accessible."""
from pathlib import Path
# Check project structure
test_dir = Path(__file__).parent
src_dir = test_dir.parent
project_root = src_dir.parent
assert test_dir.exists()
assert src_dir.exists()
assert project_root.exists()
@pytest.mark.integration
def test_environment_imports_work(self) -> None:
"""Test core imports work from environment."""
# These should all import without error
from gnn import get_module_info
from render import get_module_info as render_info
from report import get_module_info as report_info
assert get_module_info() is not None
assert render_info() is not None
assert report_info() is not None
class TestEnvironmentModuleIntegration:
"""Tests for environment integration with modules."""
@pytest.mark.integration
def test_all_modules_have_info(self) -> None:
"""Test all modules provide info."""
modules_with_info = [
'gnn',
'render',
'report',
'audio',
'visualization'
]
for module_name in modules_with_info:
try:
module = __import__(module_name)
if hasattr(module, 'get_module_info'):
info = module.get_module_info()
assert info is not None
except ImportError:
pass # Module may have optional deps
@pytest.mark.integration
def test_module_features_accessible(self) -> None:
"""Test module features are accessible."""
from audio import FEATURES
from report import FEATURES as REPORT_FEATURES
assert isinstance(FEATURES, dict)
assert isinstance(REPORT_FEATURES, dict)
class TestEnvironmentPipelineIntegration:
"""Tests for environment integration with pipeline execution."""
@pytest.mark.integration
def test_pipeline_finds_scripts(self) -> None:
"""Test pipeline can find step scripts."""
from pathlib import Path
src_dir = Path(__file__).parent.parent
# Check for numbered script files
scripts = list(src_dir.glob("[0-9]*.py")) + list(src_dir.glob("[0-9][0-9]_*.py"))
# Should find some pipeline scripts
assert isinstance(scripts, list)
@pytest.mark.integration
def test_output_directory_creation(self, tmp_path: Any) -> None:
"""Test output directory can be created."""
output_dir = tmp_path / "output"
output_dir.mkdir(parents=True, exist_ok=True)
assert output_dir.exists()
assert output_dir.is_dir()
@pytest.mark.integration
def test_temp_directory_creation(self, tmp_path: Any) -> None:
"""Test temporary directories can be created."""
temp_dir = tmp_path / "temp"
temp_dir.mkdir(parents=True, exist_ok=True)
# Should be writable
test_file = temp_dir / "test.txt"
test_file.write_text("test")
assert test_file.exists()
class TestEnvironmentLoggingIntegration:
"""Tests for environment logging integration."""
@pytest.mark.integration
def test_logging_configuration(self) -> None:
"""Test logging can be configured."""
import logging
logger = logging.getLogger("test_env")
logger.setLevel(logging.DEBUG)
# Should be able to log without error
logger.debug("Debug message")
logger.info("Info message")
logger.warning("Warning message")
@pytest.mark.integration
def test_log_file_creation(self, tmp_path: Any) -> None:
"""Test log files can be created."""
import logging
log_file = tmp_path / "test.log"
handler = logging.FileHandler(log_file)
logger = logging.getLogger("test_log_file")
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.info("Test log entry")
handler.flush()
handler.close()
assert log_file.exists()
class TestEnvironmentResourceIntegration:
"""Tests for environment resource access."""
@pytest.mark.integration
def test_input_directory_access(self, sample_gnn_files: Any) -> None:
"""Test input directories are accessible."""
if sample_gnn_files:
for gnn_file in sample_gnn_files.values():
assert gnn_file.exists()
assert gnn_file.is_file()
@pytest.mark.integration
def test_memory_availability(self) -> None:
"""Test sufficient memory is available."""
import numpy as np
# Try to allocate a reasonable array
try:
arr = np.zeros((1000, 1000))
assert arr.shape == (1000, 1000)
except MemoryError:
pytest.fail("Insufficient memory")
@pytest.mark.integration
def test_disk_space_available(self, tmp_path: Any) -> None:
"""Test sufficient disk space is available."""
# Write some test data
test_file = tmp_path / "space_test.bin"
test_file.write_bytes(b"0" * 10000) # 10KB
assert test_file.exists()
assert test_file.stat().st_size >= 10000