Spaces:
Runtime error
Runtime error
Update tests/test_violation_log.py
Browse files
tests/test_violation_log.py
CHANGED
|
@@ -1,13 +1,18 @@
|
|
| 1 |
import pytest
|
|
|
|
| 2 |
from app import save_snapshot, log_violation
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def test_log_violation():
|
|
|
|
| 5 |
violation_data = {
|
| 6 |
'site_id': "Site1",
|
|
|
|
| 7 |
'violation_type': "No Helmet",
|
| 8 |
-
'timestamp':
|
| 9 |
-
'snapshot_url': save_snapshot(
|
| 10 |
'severity': "Critical"
|
| 11 |
}
|
| 12 |
log_violation(violation_data)
|
| 13 |
-
assert os.path.exists("
|
|
|
|
| 1 |
import pytest
|
| 2 |
+
import os
|
| 3 |
from app import save_snapshot, log_violation
|
| 4 |
+
import numpy as np
|
| 5 |
+
import cv2
|
| 6 |
|
| 7 |
def test_log_violation():
|
| 8 |
+
frame = np.zeros((640, 640, 3), dtype=np.uint8)
|
| 9 |
violation_data = {
|
| 10 |
'site_id': "Site1",
|
| 11 |
+
'camera_id': "Camera1",
|
| 12 |
'violation_type': "No Helmet",
|
| 13 |
+
'timestamp': "2025-06-07T09:23:00Z",
|
| 14 |
+
'snapshot_url': save_snapshot(frame),
|
| 15 |
'severity': "Critical"
|
| 16 |
}
|
| 17 |
log_violation(violation_data)
|
| 18 |
+
assert os.path.exists("/snapshots/violation_logs.json"), "Violation logs file not found"
|