Repository navigation
test: cover the policy logic in safety_app.py - #21
Merged
Merged
Conversation
Add tests for the PPE, proximity and exclusion/inclusion-zone rules and their helpers. utils.plots is stubbed at import so the tests run in the unit job without torch; shapely is added to requirements-test.txt. Three tests are strict xfails describing behaviour that looks wrong: detect_ppe only reports the last person's result, detect_zone raises IndexError on an empty polygon, and max_allowed is compared with the count in the whole frame instead of the zone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
tests/test_safety_app.py: 58 tests for the PPE, proximity and exclusion/inclusion-zone rules and their helpers. They run in the existing unit job;utils.plotsis stubbed at import so torch isn't needed, andshapelyis added torequirements-test.txt.Three tests are marked
xfail(strict=True)because they describe behaviour that looks wrong to me. I've leftsafety_app.pyuntouched so you can decide:detect_ppedepends on detection order.flagis reassigned for every person, so only the last person inbox_listdecides the result. With two people and a "not wearing a hardhat" policy, the violation is reported when the violator is listed last and missed when listed first.detect_zoneraisesIndexErroron an empty polygon. A zone policy saved without a drawn polygon reaches it as[], notNone.max_allowedis compared with the count in the whole frame. Withmax_allowed=1, one person inside the zone and one outside is flagged. This one may be intended.Happy to follow up with fixes for whichever of these you agree are bugs.