Fix code formatting for test_maintainer.py

This commit is contained in:
kirill kulakov 2026-01-15 22:03:22 -06:00
parent 0e27fe6530
commit bc7d321cc5

View File

@ -1,19 +1,19 @@
import unittest import unittest
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import sys import sys
import datetime import datetime
# Mock complex imports before importing maintainer # Mock complex imports before importing maintainer
sys.modules['frigate.comms.inter_process'] = MagicMock() sys.modules["frigate.comms.inter_process"] = MagicMock()
sys.modules['frigate.comms.detections_updater'] = MagicMock() sys.modules["frigate.comms.detections_updater"] = MagicMock()
sys.modules['frigate.comms.recordings_updater'] = MagicMock() sys.modules["frigate.comms.recordings_updater"] = MagicMock()
sys.modules['frigate.config.camera.updater'] = MagicMock() sys.modules["frigate.config.camera.updater"] = MagicMock()
# Now import the class under test # Now import the class under test
from frigate.record.maintainer import RecordingMaintainer from frigate.record.maintainer import RecordingMaintainer
from frigate.config import FrigateConfig from frigate.config import FrigateConfig
class TestMaintainer(unittest.IsolatedAsyncioTestCase): class TestMaintainer(unittest.IsolatedAsyncioTestCase):
async def test_move_files_survives_bad_filename(self): async def test_move_files_survives_bad_filename(self):
config = MagicMock(spec=FrigateConfig) config = MagicMock(spec=FrigateConfig)
@ -27,12 +27,14 @@ class TestMaintainer(unittest.IsolatedAsyncioTestCase):
# Mock filesystem # Mock filesystem
# One bad file, one good file # One bad file, one good file
files = ['bad_filename.mp4', 'camera@20210101000000+0000.mp4'] files = ["bad_filename.mp4", "camera@20210101000000+0000.mp4"]
with patch('os.listdir', return_value=files): with patch("os.listdir", return_value=files):
with patch('os.path.isfile', return_value=True): with patch("os.path.isfile", return_value=True):
with patch('frigate.record.maintainer.psutil.process_iter', return_value=[]): with patch(
with patch('frigate.record.maintainer.logger.warning') as warn: "frigate.record.maintainer.psutil.process_iter", return_value=[]
):
with patch("frigate.record.maintainer.logger.warning") as warn:
# Mock validate_and_move_segment to avoid further logic # Mock validate_and_move_segment to avoid further logic
maintainer.validate_and_move_segment = MagicMock() maintainer.validate_and_move_segment = MagicMock()
@ -61,5 +63,6 @@ class TestMaintainer(unittest.IsolatedAsyncioTestCase):
f"Expected a single warning for bad filename, got {len(matching)}", f"Expected a single warning for bad filename, got {len(matching)}",
) )
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main() unittest.main()