Skip to content

Commit c673d35

Browse files
linter fix
1 parent 7a4de43 commit c673d35

File tree

6 files changed

+212
-158
lines changed

6 files changed

+212
-158
lines changed

tests/validation/Engine/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ from Engine.output_validator import output_validator
4545
def test_media_proxy():
4646
# Run media proxy
4747
# ...
48-
48+
4949
# Validate output
5050
result = output_validator.validate_media_proxy(
5151
output=output_text,
5252
test_name="test_media_proxy",
5353
duration=execution_time
5454
)
55-
55+
5656
assert result["is_pass"], f"Media proxy test failed: {result['errors']}"
5757
```
5858

tests/validation/Engine/csv_report.py

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@
4747
def initialize_csv_report(log_dir: Optional[str] = None) -> None:
4848
"""
4949
Initialize CSV report files.
50-
50+
5151
Args:
5252
log_dir: Directory where report files will be stored
5353
"""
5454
global _test_results, _compliance_results
5555
_test_results = []
5656
_compliance_results = {}
57-
57+
5858
# Create log directory if it doesn't exist
5959
if log_dir:
6060
Path(log_dir).mkdir(parents=True, exist_ok=True)
@@ -70,7 +70,7 @@ def csv_add_test(
7070
) -> None:
7171
"""
7272
Add a test result to the CSV report.
73-
73+
7474
Args:
7575
test_name: Name of the test
7676
test_description: Description of the test
@@ -80,70 +80,78 @@ def csv_add_test(
8080
error_message: Error message if test failed
8181
"""
8282
global _test_results
83-
83+
8484
test_result = "PASS" if result else "FAIL"
8585
test_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
86-
87-
_test_results.append({
88-
TEST_NAME_COLUMN: test_name,
89-
TEST_DESC_COLUMN: test_description,
90-
COMPONENT_COLUMN: component,
91-
TEST_RESULT_COLUMN: test_result,
92-
TEST_TIME_COLUMN: test_time,
93-
TEST_DURATION_COLUMN: f"{duration:.2f}s",
94-
TEST_ERROR_COLUMN: error_message
95-
})
96-
86+
87+
_test_results.append(
88+
{
89+
TEST_NAME_COLUMN: test_name,
90+
TEST_DESC_COLUMN: test_description,
91+
COMPONENT_COLUMN: component,
92+
TEST_RESULT_COLUMN: test_result,
93+
TEST_TIME_COLUMN: test_time,
94+
TEST_DURATION_COLUMN: f"{duration:.2f}s",
95+
TEST_ERROR_COLUMN: error_message
96+
}
97+
)
98+
9799
logger.info(f"Added test result: {test_name} - {test_result}")
98100

99101

100102
def update_compliance_result(requirement_id: str, is_compliant: bool) -> None:
101103
"""
102104
Update compliance result for a specific requirement.
103-
105+
104106
Args:
105107
requirement_id: ID of the requirement
106108
is_compliant: True if compliant, False if not
107109
"""
108110
global _compliance_results
109-
111+
110112
_compliance_results[requirement_id] = is_compliant
111-
logger.info(f"Updated compliance for {requirement_id}: {'COMPLIANT' if is_compliant else 'NON-COMPLIANT'}")
113+
logger.info(
114+
f"Updated compliance for {requirement_id}: {'COMPLIANT' if is_compliant else 'NON-COMPLIANT'}"
115+
)
112116

113117

114118
def csv_write_report(log_dir: str = ".") -> None:
115119
"""
116120
Write test results and compliance results to CSV files.
117-
121+
118122
Args:
119123
log_dir: Directory where report files will be stored
120124
"""
121125
report_path = Path(log_dir) / CSV_REPORT_FILE
122126
compliance_path = Path(log_dir) / COMPLIANCE_REPORT_FILE
123-
127+
124128
# Write test results
125129
if _test_results:
126130
try:
127-
with open(report_path, 'w', newline='') as csvfile:
131+
with open(report_path, "w", newline='') as csvfile:
128132
writer = csv.DictWriter(csvfile, fieldnames=CSV_HEADERS)
129133
writer.writeheader()
130134
for result in _test_results:
131135
writer.writerow(result)
132136
logger.info(f"Test report written to {report_path}")
133137
except Exception as e:
134138
logger.error(f"Failed to write test report: {e}")
135-
139+
136140
# Write compliance results
137141
if _compliance_results:
138142
try:
139-
with open(compliance_path, 'w', newline='') as csvfile:
140-
writer = csv.DictWriter(csvfile, fieldnames=['Requirement ID', 'Status'])
143+
with open(compliance_path, "w", newline='') as csvfile:
144+
writer = csv.DictWriter(
145+
csvfile, fieldnames=['Requirement ID', 'Status']
146+
)
141147
writer.writeheader()
142148
for req_id, is_compliant in _compliance_results.items():
143-
writer.writerow({
144-
'Requirement ID': req_id,
145-
'Status': 'COMPLIANT' if is_compliant else 'NON-COMPLIANT'
146-
})
149+
writer.writerow(
150+
{
151+
'Requirement ID': req_id,
152+
'Status': 'COMPLIANT' if is_compliant else 'NON-COMPLIANT',
153+
}
154+
)
147155
logger.info(f"Compliance report written to {compliance_path}")
148156
except Exception as e:
149157
logger.error(f"Failed to write compliance report: {e}")
@@ -152,31 +160,33 @@ def csv_write_report(log_dir: str = ".") -> None:
152160
def get_test_summary() -> Dict[str, int | str]:
153161
"""
154162
Get a summary of test results.
155-
163+
156164
Returns:
157165
Dictionary with total, passed, and failed test counts and pass rate
158166
"""
159167
pass_count = sum(1 for r in _test_results if r[TEST_RESULT_COLUMN] == "PASS")
160168
fail_count = sum(1 for r in _test_results if r[TEST_RESULT_COLUMN] == "FAIL")
161169
total_count = len(_test_results)
162-
170+
163171
return {
164172
"total": total_count,
165173
"passed": pass_count,
166174
"failed": fail_count,
167-
"pass_rate": f"{(pass_count / total_count * 100):.1f}%" if total_count > 0 else "N/A"
175+
"pass_rate": (
176+
f"{(pass_count / total_count * 100):.1f}%" if total_count > 0 else "N/A"
177+
),
168178
}
169179

170180

171181
def get_component_summary() -> Dict[str, Dict[str, int | str]]:
172182
"""
173183
Get a summary of test results by component.
174-
184+
175185
Returns:
176186
Dictionary with component-wise test summaries
177187
"""
178188
components = {}
179-
189+
180190
for result in _test_results:
181191
component = result[COMPONENT_COLUMN]
182192
if component not in components:
@@ -187,30 +197,36 @@ def get_component_summary() -> Dict[str, Dict[str, int | str]]:
187197
components[component]["passed"] += 1
188198
else:
189199
components[component]["failed"] += 1
190-
200+
191201
# Add pass rate
192202
for component in components:
193203
total = components[component]["total"]
194204
passed = components[component]["passed"]
195-
components[component]["pass_rate"] = f"{(passed / total * 100):.1f}%" if total > 0 else "N/A"
196-
205+
components[component]["pass_rate"] = (
206+
f"{(passed / total * 100):.1f}%" if total > 0 else "N/A"
207+
)
208+
197209
return components
198210

199211

200212
def get_compliance_summary() -> Dict[str, int | str]:
201213
"""
202214
Get a summary of compliance results.
203-
215+
204216
Returns:
205217
Dictionary with total, compliant, and non-compliant counts and compliance rate
206218
"""
207219
compliant_count = sum(1 for v in _compliance_results.values() if v)
208220
non_compliant_count = sum(1 for v in _compliance_results.values() if not v)
209221
total_count = len(_compliance_results)
210-
222+
211223
return {
212224
"total": total_count,
213225
"compliant": compliant_count,
214226
"non_compliant": non_compliant_count,
215-
"compliance_rate": f"{(compliant_count / total_count * 100):.1f}%" if total_count > 0 else "N/A"
227+
"compliance_rate": (
228+
f"{(compliant_count / total_count * 100):.1f}%"
229+
if total_count > 0
230+
else "N/A"
231+
),
216232
}

0 commit comments

Comments
 (0)