Skip to content

Commit f226881

Browse files
linter fix 2
1 parent c673d35 commit f226881

File tree

5 files changed

+91
-166
lines changed

5 files changed

+91
-166
lines changed

tests/validation/Engine/csv_report.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
_test_results = []
4545
_compliance_results = {}
4646

47+
4748
def initialize_csv_report(log_dir: Optional[str] = None) -> None:
4849
"""
4950
Initialize CSV report files.
@@ -92,7 +93,7 @@ def csv_add_test(
9293
TEST_RESULT_COLUMN: test_result,
9394
TEST_TIME_COLUMN: test_time,
9495
TEST_DURATION_COLUMN: f"{duration:.2f}s",
95-
TEST_ERROR_COLUMN: error_message
96+
TEST_ERROR_COLUMN: error_message,
9697
}
9798
)
9899

@@ -110,9 +111,7 @@ def update_compliance_result(requirement_id: str, is_compliant: bool) -> None:
110111
global _compliance_results
111112

112113
_compliance_results[requirement_id] = is_compliant
113-
logger.info(
114-
f"Updated compliance for {requirement_id}: {'COMPLIANT' if is_compliant else 'NON-COMPLIANT'}"
115-
)
114+
logger.info(f"Updated compliance for {requirement_id}: {'COMPLIANT' if is_compliant else 'NON-COMPLIANT'}")
116115

117116

118117
def csv_write_report(log_dir: str = ".") -> None:
@@ -128,7 +127,7 @@ def csv_write_report(log_dir: str = ".") -> None:
128127
# Write test results
129128
if _test_results:
130129
try:
131-
with open(report_path, "w", newline='') as csvfile:
130+
with open(report_path, "w", newline="") as csvfile:
132131
writer = csv.DictWriter(csvfile, fieldnames=CSV_HEADERS)
133132
writer.writeheader()
134133
for result in _test_results:
@@ -140,16 +139,14 @@ def csv_write_report(log_dir: str = ".") -> None:
140139
# Write compliance results
141140
if _compliance_results:
142141
try:
143-
with open(compliance_path, "w", newline='') as csvfile:
144-
writer = csv.DictWriter(
145-
csvfile, fieldnames=['Requirement ID', 'Status']
146-
)
142+
with open(compliance_path, "w", newline="") as csvfile:
143+
writer = csv.DictWriter(csvfile, fieldnames=["Requirement ID", "Status"])
147144
writer.writeheader()
148145
for req_id, is_compliant in _compliance_results.items():
149146
writer.writerow(
150147
{
151-
'Requirement ID': req_id,
152-
'Status': 'COMPLIANT' if is_compliant else 'NON-COMPLIANT',
148+
"Requirement ID": req_id,
149+
"Status": "COMPLIANT" if is_compliant else "NON-COMPLIANT",
153150
}
154151
)
155152
logger.info(f"Compliance report written to {compliance_path}")
@@ -172,9 +169,7 @@ def get_test_summary() -> Dict[str, int | str]:
172169
"total": total_count,
173170
"passed": pass_count,
174171
"failed": fail_count,
175-
"pass_rate": (
176-
f"{(pass_count / total_count * 100):.1f}%" if total_count > 0 else "N/A"
177-
),
172+
"pass_rate": (f"{(pass_count / total_count * 100):.1f}%" if total_count > 0 else "N/A"),
178173
}
179174

180175

@@ -191,7 +186,7 @@ def get_component_summary() -> Dict[str, Dict[str, int | str]]:
191186
component = result[COMPONENT_COLUMN]
192187
if component not in components:
193188
components[component] = {"total": 0, "passed": 0, "failed": 0}
194-
189+
195190
components[component]["total"] += 1
196191
if result[TEST_RESULT_COLUMN] == "PASS":
197192
components[component]["passed"] += 1
@@ -202,9 +197,7 @@ def get_component_summary() -> Dict[str, Dict[str, int | str]]:
202197
for component in components:
203198
total = components[component]["total"]
204199
passed = components[component]["passed"]
205-
components[component]["pass_rate"] = (
206-
f"{(passed / total * 100):.1f}%" if total > 0 else "N/A"
207-
)
200+
components[component]["pass_rate"] = f"{(passed / total * 100):.1f}%" if total > 0 else "N/A"
208201

209202
return components
210203

@@ -224,9 +217,5 @@ def get_compliance_summary() -> Dict[str, int | str]:
224217
"total": total_count,
225218
"compliant": compliant_count,
226219
"non_compliant": non_compliant_count,
227-
"compliance_rate": (
228-
f"{(compliant_count / total_count * 100):.1f}%"
229-
if total_count > 0
230-
else "N/A"
231-
),
220+
"compliance_rate": (f"{(compliant_count / total_count * 100):.1f}%" if total_count > 0 else "N/A"),
232221
}

tests/validation/Engine/html_report.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ def generate_html_report(log_dir: str = ".") -> None:
4141

4242
# Read CSV data
4343
test_results = []
44-
with open(report_path, "r", newline='') as csvfile:
44+
with open(report_path, "r", newline="") as csvfile:
4545
reader = csv.DictReader(csvfile)
4646
for row in reader:
4747
test_results.append(row)
4848

4949
# Read compliance data if available
5050
compliance_results = []
5151
if compliance_path.exists():
52-
with open(compliance_path, "r", newline='') as csvfile:
52+
with open(compliance_path, "r", newline="") as csvfile:
5353
reader = csv.DictReader(csvfile)
5454
for row in reader:
5555
compliance_results.append(row)
@@ -231,9 +231,10 @@ def generate_html_report(log_dir: str = ".") -> None:
231231
<p>Pass Rate: <strong>{summary['pass_rate']}</strong></p>
232232
</div>
233233
"""
234-
)
234+
)
235235

236-
f.write("""
236+
f.write(
237+
"""
237238
</div>
238239
</div>
239240
"""
@@ -255,10 +256,11 @@ def generate_html_report(log_dir: str = ".") -> None:
255256
</div>
256257
</div>
257258
"""
258-
)
259+
)
259260

260261
# Test results filter
261-
f.write("""
262+
f.write(
263+
"""
262264
<h2>Test Results</h2>
263265
<div class="filter-container">
264266
<label>
@@ -294,11 +296,11 @@ def generate_html_report(log_dir: str = ".") -> None:
294296

295297
# Test results
296298
for result in test_results:
297-
component = result.get('Component', '')
299+
component = result.get("Component", "")
298300
component_class = component.lower().replace(" ", "-")
299-
result_class = 'pass' if result.get('Test Result') == 'PASS' else 'fail'
300-
error_msg = result.get('Error Message', '')
301-
301+
result_class = "pass" if result.get("Test Result") == "PASS" else "fail"
302+
error_msg = result.get("Error Message", "")
303+
302304
f.write(
303305
f"""
304306
<tr class="{result_class}" data-component="{component}">
@@ -309,34 +311,37 @@ def generate_html_report(log_dir: str = ".") -> None:
309311
<td>{result.get('Test Time', '')}</td>
310312
<td>
311313
"""
312-
)
314+
)
313315
if error_msg:
314316
f.write(
315-
f"""
317+
f"""
316318
<button class="collapsible">Show Error Details</button>
317319
<div class="content">
318320
<div class="error-detail">{error_msg}</div>
319321
</div>
320322
"""
321-
)
323+
)
322324
else:
323325
f.write("N/A")
324-
325-
f.write("""
326+
327+
f.write(
328+
"""
326329
</td>
327330
</tr>
328331
"""
329-
)
332+
)
330333

331-
f.write("""
334+
f.write(
335+
"""
332336
</tbody>
333337
</table>
334338
"""
335339
)
336340

337341
# Compliance results if available
338342
if compliance_results:
339-
f.write("""
343+
f.write(
344+
"""
340345
<h2>Compliance Results</h2>
341346
<table>
342347
<thead>
@@ -347,26 +352,28 @@ def generate_html_report(log_dir: str = ".") -> None:
347352
</thead>
348353
<tbody>
349354
"""
350-
)
355+
)
351356
for result in compliance_results:
352-
status = result.get('Status', '')
353-
result_class = 'pass' if status == 'COMPLIANT' else 'fail'
357+
status = result.get("Status", "")
358+
result_class = "pass" if status == "COMPLIANT" else "fail"
354359
f.write(
355-
f"""
360+
f"""
356361
<tr class="{result_class}">
357362
<td>{result.get('Requirement ID', '')}</td>
358363
<td>{status}</td>
359364
</tr>
360365
"""
361-
)
362-
f.write("""
366+
)
367+
f.write(
368+
"""
363369
</tbody>
364370
</table>
365371
"""
366-
)
372+
)
367373

368374
# JavaScript for filtering and collapsible elements
369-
f.write("""
375+
f.write(
376+
"""
370377
<script>
371378
// Filter functionality
372379
document.getElementById('showPassed').addEventListener('change', filterResults);

tests/validation/Engine/logging_utils.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def log_test_result(
4141
test_name: Name of the test
4242
test_description: Description of the test
4343
error_message: Error message if test failed
44-
44+
4545
Returns:
4646
Decorated function
4747
"""
@@ -52,7 +52,7 @@ def wrapper(*args, **kwargs) -> Any:
5252
start_time = time.time()
5353
result = True
5454
error = ""
55-
55+
5656
try:
5757
func_result = func(*args, **kwargs)
5858
return func_result
@@ -69,17 +69,15 @@ def wrapper(*args, **kwargs) -> Any:
6969
component=component,
7070
result=result,
7171
duration=duration,
72-
error_message=error_message or error
72+
error_message=error_message or error,
7373
)
74-
74+
7575
return wrapper
7676

7777
return decorator
7878

7979

80-
def log_ffmpeg_test(
81-
test_name: str, test_description: str = "", error_message: str = ""
82-
) -> Callable:
80+
def log_ffmpeg_test(test_name: str, test_description: str = "", error_message: str = "") -> Callable:
8381
"""Decorator to log FFmpeg test results"""
8482
return log_test_result(
8583
component=COMPONENT_FFMPEG,
@@ -89,9 +87,7 @@ def log_ffmpeg_test(
8987
)
9088

9189

92-
def log_media_proxy_test(
93-
test_name: str, test_description: str = "", error_message: str = ""
94-
) -> Callable:
90+
def log_media_proxy_test(test_name: str, test_description: str = "", error_message: str = "") -> Callable:
9591
"""Decorator to log Media Proxy test results"""
9692
return log_test_result(
9793
component=COMPONENT_MEDIA_PROXY,
@@ -101,9 +97,7 @@ def log_media_proxy_test(
10197
)
10298

10399

104-
def log_mesh_agent_test(
105-
test_name: str, test_description: str = "", error_message: str = ""
106-
) -> Callable:
100+
def log_mesh_agent_test(test_name: str, test_description: str = "", error_message: str = "") -> Callable:
107101
"""Decorator to log Mesh Agent test results"""
108102
return log_test_result(
109103
component=COMPONENT_MESH_AGENT,
@@ -113,9 +107,7 @@ def log_mesh_agent_test(
113107
)
114108

115109

116-
def log_rxtx_app_test(
117-
test_name: str, test_description: str = "", error_message: str = ""
118-
) -> Callable:
110+
def log_rxtx_app_test(test_name: str, test_description: str = "", error_message: str = "") -> Callable:
119111
"""Decorator to log RxTx App test results"""
120112
return log_test_result(
121113
component=COMPONENT_RXTX_APP,
@@ -135,17 +127,15 @@ def parse_output_for_errors(
135127
component: Component name (FFmpeg, Media Proxy, Mesh Agent, RxTx App)
136128
output: Output text to parse
137129
custom_error_keywords: Custom error keywords to use instead of component defaults
138-
130+
139131
Returns:
140132
Dictionary with is_pass and errors fields
141133
"""
142134
if component not in COMPONENT_ERROR_KEYWORDS and not custom_error_keywords:
143135
logger.warning(f"Unknown component: {component}, using generic error keywords")
144136
error_keywords = ["error", "failed", "exception", "fatal"]
145137
else:
146-
error_keywords = custom_error_keywords or COMPONENT_ERROR_KEYWORDS.get(
147-
component, []
148-
)
138+
error_keywords = custom_error_keywords or COMPONENT_ERROR_KEYWORDS.get(component, [])
149139

150140
errors = []
151141
for line in output.splitlines():
@@ -174,7 +164,7 @@ def streamline_component_output_validation(
174164
test_name: Name of the test
175165
duration: Test duration in seconds
176166
custom_error_keywords: Custom error keywords to use
177-
167+
178168
Returns:
179169
Dictionary with is_pass and errors fields
180170
"""

0 commit comments

Comments
 (0)