Skip to content

test: cover the policy logic in safety_app.py - #21

Merged
codelion merged 1 commit into
securade:mainfrom
Emart29:test/safety-app-policy-logic
Oct 4, 2026
Merged

codelion merged 1 commit into
securade:mainfrom
Emart29:test/safety-app-policy-logic

Conversation

@Emart29

@Emart29 Emart29 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

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.plots is stubbed at import so torch isn't needed, and shapely is added to requirements-test.txt.

Three tests are marked xfail(strict=True) because they describe behaviour that looks wrong to me. I've left safety_app.py untouched so you can decide:

  1. detect_ppe depends on detection order. flag is reassigned for every person, so only the last person in box_list decides 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.
  2. detect_zone raises IndexError on an empty polygon. A zone policy saved without a drawn polygon reaches it as [], not None.
  3. max_allowed is compared with the count in the whole frame. With max_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.

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.
@codelion
codelion merged commit ac03d08 into securade:main Oct 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants