-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for recordings retention and fix bug (#7183)
* Add tests for segment info * Fix logic
- Loading branch information
Showing
2 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import unittest | ||
|
||
from frigate.config import RetainModeEnum | ||
from frigate.record.maintainer import SegmentInfo | ||
|
||
|
||
class TestRecordRetention(unittest.TestCase): | ||
def test_motion_should_keep_motion_not_object(self): | ||
segment_info = SegmentInfo( | ||
motion_box_count=1, active_object_count=0, average_dBFS=0 | ||
) | ||
assert not segment_info.should_discard_segment(RetainModeEnum.motion) | ||
assert segment_info.should_discard_segment(RetainModeEnum.active_objects) | ||
|
||
def test_object_should_keep_object_not_motion(self): | ||
segment_info = SegmentInfo( | ||
motion_box_count=0, active_object_count=1, average_dBFS=0 | ||
) | ||
assert segment_info.should_discard_segment(RetainModeEnum.motion) | ||
assert not segment_info.should_discard_segment(RetainModeEnum.active_objects) | ||
|
||
def test_all_should_keep_all(self): | ||
segment_info = SegmentInfo( | ||
motion_box_count=0, active_object_count=0, average_dBFS=0 | ||
) | ||
assert not segment_info.should_discard_segment(RetainModeEnum.all) | ||
|
||
def test_should_keep_audio_in_motion_mode(self): | ||
segment_info = SegmentInfo( | ||
motion_box_count=0, active_object_count=0, average_dBFS=1 | ||
) | ||
assert not segment_info.should_discard_segment(RetainModeEnum.motion) | ||
assert segment_info.should_discard_segment(RetainModeEnum.active_objects) |