Testing
The zmeventnotificationNg project has two tiers of tests: unit tests that need no special hardware, and end-to-end (e2e) tests that run real ML models through the full config-to-detection chain.
None of the tests require a running ZoneMinder instance.
Running all tests
cd zmeventnotificationNg
# Perl tests
prove -I t/lib -I . -r t/
# Python tests (unit + e2e)
cd hook && python3 -m pytest tests/ -v && cd ..
Unit / integration tests
These tests mock pyzmNg and use no real models. They run anywhere:
# Perl
prove -I t/lib -I . -r t/
# Python
pip install pytest pyyaml
cd hook && python3 -m pytest tests/ -m "not e2e" -v
End-to-end tests
The hook/tests/test_e2e/ directory contains tests that exercise
the full objectconfig YAML → pyzmNg detection → output chain using real
YOLO models and a real test image (bird.jpg, included in the repo).
These tests use real pyzmNg (installed as a system library, not
mocked) and call the same functions that zm_detect.py uses:
process_config() → secret substitution → Detector.from_dict() →
detector.detect() → format_detection_output().
Prerequisites:
pyzm installed (
pip install pyzmor from source)ML models at
/var/lib/zmeventnotification/models/(at least one YOLO model, e.g.yolov4/orultralytics/)Python packages:
opencv-python,numpy,shapely
Run all e2e tests:
cd hook
python3 -m pytest tests/test_e2e/ -v
Run a single test file:
python3 -m pytest tests/test_e2e/test_pattern_config.py -v
Test file reference
File |
Tests |
What it covers |
|---|---|---|
|
5 |
Full config→detect→output chain, output format, show_percent,
image in matched_data, |
|
2 |
|
|
3 |
Restrictive pattern (no matches), broad pattern (matches), specific label-only pattern |
|
3 |
High threshold filters, low threshold keeps, low vs high comparison |
|
2 |
|
|
3 |
Per-monitor ml_sequence override, zone parsing, per-monitor config key override (show_percent) |
|
2 |
UNION strategy (both models), FIRST strategy (first model only) |
|
3 |
Full-image zone keeps detections, tiny zone filters all, zone with restrictive pattern |
|
3 |
JSON roundtrip validity, label-confidence correlation, bounding box coordinates valid |
Test dependencies
Tier |
Dependencies |
|---|---|
Perl |
|
Python (unit) |
|
Python (e2e) |
all of the above plus |
Pytest markers
Marker |
Description |
|---|---|
|
End-to-end tests requiring real pyzmNg, models, and images on disk |