mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-23 19:11:14 +01:00
ab50d0b006
* Add isort and ruff linter Both linters are pretty common among modern python code bases. The isort tool provides stable sorting and grouping, as well as pruning of unused imports. Ruff is a modern linter, that is very fast due to being written in rust. It can detect many common issues in a python codebase. Removes the pylint dev requirement, since ruff replaces it. * treewide: fix issues detected by ruff * treewide: fix bare except clauses * .devcontainer: Set up isort * treewide: optimize imports * treewide: apply black * treewide: make regex patterns raw strings This is necessary for escape sequences to be properly recognized.
27 lines
702 B
Python
27 lines
702 B
Python
from unittest import TestCase, main
|
|
|
|
from frigate.video import box_overlaps, reduce_boxes
|
|
|
|
|
|
class TestBoxOverlaps(TestCase):
|
|
def test_overlap(self):
|
|
assert box_overlaps((100, 100, 200, 200), (50, 50, 150, 150))
|
|
|
|
def test_overlap_2(self):
|
|
assert box_overlaps((50, 50, 150, 150), (100, 100, 200, 200))
|
|
|
|
def test_no_overlap(self):
|
|
assert not box_overlaps((100, 100, 200, 200), (250, 250, 350, 350))
|
|
|
|
|
|
class TestReduceBoxes(TestCase):
|
|
def test_cluster(self):
|
|
clusters = reduce_boxes(
|
|
[(144, 290, 221, 459), (225, 178, 426, 341), (343, 105, 584, 250)]
|
|
)
|
|
assert len(clusters) == 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(verbosity=2)
|