2023-07-16 20:07:15 +02:00
|
|
|
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):
|
2024-03-15 16:29:22 +01:00
|
|
|
segment_info = SegmentInfo(
|
2024-03-15 20:13:40 +01:00
|
|
|
motion_count=1, active_object_count=0, region_count=0, average_dBFS=0
|
2024-03-15 16:29:22 +01:00
|
|
|
)
|
2023-07-16 20:07:15 +02:00
|
|
|
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):
|
2024-03-15 16:29:22 +01:00
|
|
|
segment_info = SegmentInfo(
|
2024-03-15 20:13:40 +01:00
|
|
|
motion_count=0, active_object_count=1, region_count=0, average_dBFS=0
|
2024-03-15 16:29:22 +01:00
|
|
|
)
|
2023-07-16 20:07:15 +02:00
|
|
|
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):
|
2024-03-15 16:29:22 +01:00
|
|
|
segment_info = SegmentInfo(
|
2024-03-15 20:13:40 +01:00
|
|
|
motion_count=0, active_object_count=0, region_count=0, average_dBFS=0
|
2024-03-15 16:29:22 +01:00
|
|
|
)
|
2023-07-16 20:07:15 +02:00
|
|
|
assert not segment_info.should_discard_segment(RetainModeEnum.all)
|
|
|
|
|
|
|
|
def test_should_keep_audio_in_motion_mode(self):
|
2024-03-15 16:29:22 +01:00
|
|
|
segment_info = SegmentInfo(
|
2024-03-15 20:13:40 +01:00
|
|
|
motion_count=0, active_object_count=0, region_count=0, average_dBFS=1
|
2024-03-15 16:29:22 +01:00
|
|
|
)
|
2023-07-16 20:07:15 +02:00
|
|
|
assert not segment_info.should_discard_segment(RetainModeEnum.motion)
|
|
|
|
assert segment_info.should_discard_segment(RetainModeEnum.active_objects)
|