Skip to content

Commit

Permalink
fix recording tests to use adjusted_start_time
Browse files Browse the repository at this point in the history
  • Loading branch information
roflcoopter committed Aug 28, 2024
1 parent 620c80c commit b8065c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def insert_data(self, get_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier="test",
start_time=self._now + datetime.timedelta(seconds=7),
adjusted_start_time=self._now + datetime.timedelta(seconds=2),
end_time=self._now + datetime.timedelta(seconds=10),
created_at=self._now + datetime.timedelta(seconds=7),
thumbnail_path="/test/test1.jpg",
Expand All @@ -132,6 +133,7 @@ def insert_data(self, get_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier="test2",
start_time=self._now + datetime.timedelta(seconds=7),
adjusted_start_time=self._now + datetime.timedelta(seconds=2),
end_time=self._now + datetime.timedelta(seconds=10),
created_at=self._now + datetime.timedelta(seconds=7),
thumbnail_path="/test2/test4.jpg",
Expand All @@ -141,6 +143,7 @@ def insert_data(self, get_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier="test",
start_time=self._now + datetime.timedelta(seconds=26),
adjusted_start_time=self._now + datetime.timedelta(seconds=21),
end_time=self._now + datetime.timedelta(seconds=36),
created_at=self._now + datetime.timedelta(seconds=26),
thumbnail_path="/test/test2.jpg",
Expand All @@ -150,6 +153,7 @@ def insert_data(self, get_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier="test",
start_time=self._now + datetime.timedelta(seconds=40),
adjusted_start_time=self._now + datetime.timedelta(seconds=35),
end_time=self._now + datetime.timedelta(seconds=45),
created_at=self._now + datetime.timedelta(seconds=40),
thumbnail_path="/test/test3.jpg",
Expand Down
19 changes: 17 additions & 2 deletions tests/domains/camera/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import datetime
from collections.abc import Callable
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal
from unittest.mock import MagicMock, Mock, patch

import pytest
Expand Down Expand Up @@ -32,6 +32,7 @@ def get_db_session_recordings(get_db_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier=f"test{i}",
start_time=datetime.datetime(2023, 3, 1, 12, 0),
adjusted_start_time=datetime.datetime(2023, 3, 1, 12, 0),
end_time=datetime.datetime(2023, 3, 1, 12, 3),
thumbnail_path="test",
)
Expand All @@ -40,6 +41,7 @@ def get_db_session_recordings(get_db_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier=f"test{i}",
start_time=datetime.datetime(2023, 3, 1, 12, 10),
adjusted_start_time=datetime.datetime(2023, 3, 1, 12, 10),
end_time=datetime.datetime(2023, 3, 1, 12, 12),
thumbnail_path="test",
)
Expand All @@ -48,6 +50,7 @@ def get_db_session_recordings(get_db_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier=f"test{i}",
start_time=datetime.datetime(2023, 3, 2, 12, 0),
adjusted_start_time=datetime.datetime(2023, 3, 2, 12, 0),
end_time=datetime.datetime(2023, 3, 2, 12, 3),
thumbnail_path="test",
)
Expand All @@ -56,6 +59,7 @@ def get_db_session_recordings(get_db_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier=f"test{i}",
start_time=datetime.datetime(2023, 3, 2, 12, 10),
adjusted_start_time=datetime.datetime(2023, 3, 2, 12, 10),
end_time=datetime.datetime(2023, 3, 2, 12, 12),
thumbnail_path="test",
)
Expand All @@ -64,6 +68,7 @@ def get_db_session_recordings(get_db_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier=f"test{i}",
start_time=datetime.datetime(2023, 3, 3, 12, 0),
adjusted_start_time=datetime.datetime(2023, 3, 3, 12, 0),
end_time=datetime.datetime(2023, 3, 3, 12, 3),
thumbnail_path="test",
)
Expand All @@ -72,6 +77,7 @@ def get_db_session_recordings(get_db_session: Callable[[], Session]):
insert(Recordings).values(
camera_identifier=f"test{i}",
start_time=datetime.datetime(2023, 3, 3, 12, 10),
adjusted_start_time=datetime.datetime(2023, 3, 3, 12, 10),
end_time=datetime.datetime(2023, 3, 3, 12, 12),
thumbnail_path="test",
)
Expand Down Expand Up @@ -193,6 +199,15 @@ def test_delete_recordings_missing(get_db_session_recordings: Callable[[], Sessi
assert len(recordings) == 0


class Recorder(RecorderBase):
"""Recorder class."""

@property
def lookback(self) -> Literal[5]:
"""Return lookback."""
return 5


class TestRecorderBase:
"""Test the RecorderBase class."""

Expand All @@ -204,7 +219,7 @@ def test_delete_recording(
):
"""Test delete_recording."""
mock_delete_recording.return_value = []
recorder_base = RecorderBase(vis, MagicMock(), MockCamera())
recorder_base = Recorder(vis, MagicMock(), MockCamera())
result = recorder_base.delete_recording()
assert result is False

Expand Down

0 comments on commit b8065c9

Please sign in to comment.