diff --git a/wizard-work/spark/verify_dir_analyzer.py b/wizard-work/spark/verify_dir_analyzer.py index 6abd27f..89a49e7 100644 --- a/wizard-work/spark/verify_dir_analyzer.py +++ b/wizard-work/spark/verify_dir_analyzer.py @@ -4,23 +4,30 @@ import subprocess import json import sys + +def _check(cond, msg="check failed"): + """Explicit failure path -- survives `python3 -O`, where `assert` is compiled away.""" + if not cond: + raise SystemExit(f"FAIL: {msg}") + + # Test JSON mode result = subprocess.run(['python3', 'dir_analyzer.py', '/etc', '--json'], capture_output=True, text=True, cwd='/root/troupe-standup/wizard-work/spark') data = json.loads(result.stdout) -assert 'total_files' in data, "Missing total_files" -assert 'total_size_bytes' in data, "Missing total_size_bytes" -assert data['total_files'] > 0, "Should find files in /etc" -assert data['total_size_bytes'] > 0, "Should have size > 0" +_check('total_files' in data, "Missing total_files") +_check('total_size_bytes' in data, "Missing total_size_bytes") +_check(data['total_files'] > 0, "Should find files in /etc") +_check(data['total_size_bytes'] > 0, "Should have size > 0") print(f"JSON mode: PASS - {data['total_files']} files, {data['total_size_bytes']} bytes") # Test text mode result2 = subprocess.run(['python3', 'dir_analyzer.py', '/tmp'], capture_output=True, text=True, cwd='/root/troupe-standup/wizard-work/spark') -assert 'Total files:' in result2.stdout, "Should show file count" -assert 'Total size:' in result2.stdout, "Should show size" +_check('Total files:' in result2.stdout, "Should show file count") +_check('Total size:' in result2.stdout, "Should show size") print("Text mode: PASS") print("All verification tests passed") \ No newline at end of file diff --git a/wizard-work/spark/verify_report.py b/wizard-work/spark/verify_report.py index c670fb2..0b555f1 100644 --- a/wizard-work/spark/verify_report.py +++ b/wizard-work/spark/verify_report.py @@ -1,8 +1,15 @@ #!/usr/bin/env python3 import json + + +def _check(cond, msg="check failed"): + """Explicit failure path -- survives `python3 -O`, where `assert` is compiled away.""" + if not cond: + raise SystemExit(f"FAIL: {msg}") + report = json.load(open('/root/.hermes/wizard-outputs/spark/validation_report.json')) -assert report['summary']['valid_count'] == 1, "Expected 1 valid file" -assert report['summary']['invalid_count'] == 1, "Expected 1 invalid file" -assert report['test_passed'] == True, "Test should be marked as passed" +_check(report['summary']['valid_count'] == 1, "Expected 1 valid file") +_check(report['summary']['invalid_count'] == 1, "Expected 1 invalid file") +_check(report['test_passed'] == True, "Test should be marked as passed") print("All assertions passed") exit(0) \ No newline at end of file diff --git a/wizard-work/spark/verify_result.py b/wizard-work/spark/verify_result.py index 7962798..108832b 100644 --- a/wizard-work/spark/verify_result.py +++ b/wizard-work/spark/verify_result.py @@ -1,7 +1,14 @@ #!/usr/bin/env python3 import json + + +def _check(cond, msg="check failed"): + """Explicit failure path -- survives `python3 -O`, where `assert` is compiled away.""" + if not cond: + raise SystemExit(f"FAIL: {msg}") + with open("/root/.hermes/wizard-outputs/spark/scrape_result.json") as f: data = json.load(f) -assert data["title"] == "Example Domain", f"wrong title: {data['title']}" -assert data["status"] == "success", f"wrong status: {data['status']}" +_check(data["title"] == "Example Domain", f"wrong title: {data['title']}") +_check(data["status"] == "success", f"wrong status: {data['status']}") print("VALID") \ No newline at end of file diff --git a/wizard-work/spark/verify_scratch_analysis.py b/wizard-work/spark/verify_scratch_analysis.py index 3cda0dd..8f8edfb 100644 --- a/wizard-work/spark/verify_scratch_analysis.py +++ b/wizard-work/spark/verify_scratch_analysis.py @@ -3,19 +3,26 @@ import json import sys + +def _check(cond, msg="check failed"): + """Explicit failure path -- survives `python3 -O`, where `assert` is compiled away.""" + if not cond: + raise SystemExit(f"FAIL: {msg}") + + with open("/root/.hermes/wizard-outputs/spark/scratch_analysis.json") as f: data = json.load(f) # Verify required fields -assert "total_files" in data, "Missing total_files" -assert "total_bytes" in data, "Missing total_bytes" -assert "file_types" in data, "Missing file_types" -assert "files" in data, "Missing files array" +_check("total_files" in data, "Missing total_files") +_check("total_bytes" in data, "Missing total_bytes") +_check("file_types" in data, "Missing file_types") +_check("files" in data, "Missing files array") # Verify counts match -assert data["total_files"] == len(data["files"]), "File count mismatch" -assert data["total_files"] == 165, f"Expected 165 files, got {data['total_files']}" -assert 230000 <= data["total_bytes"] <= 250000, f"Total bytes out of range: {data['total_bytes']}" +_check(data["total_files"] == len(data["files"]), "File count mismatch") +_check(data["total_files"] == 165, f"Expected 165 files, got {data['total_files']}") +_check(230000 <= data["total_bytes"] <= 250000, f"Total bytes out of range: {data['total_bytes']}") print("VERIFICATION PASSED") print(f"Total files: {data['total_files']}")