From c39d93d033ad07a47d507c25a1b6aada39f7365a Mon Sep 17 00:00:00 2001 From: Glyph Date: Wed, 11 Sep 2024 17:30:37 -0700 Subject: [PATCH] record session changes This commit was sponsored by Devin Prater, Matt Campbell, Jason Mills, and my other patrons. If you want to join them, you can support my work at https://glyph.im/patrons/. --- src/pomodouroboros/model/test/test_model.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/pomodouroboros/model/test/test_model.py b/src/pomodouroboros/model/test/test_model.py index d104dee..caebedb 100644 --- a/src/pomodouroboros/model/test/test_model.py +++ b/src/pomodouroboros/model/test/test_model.py @@ -42,6 +42,18 @@ class TestInterval: T = TypeVar("T") +@dataclass +class SessionChange: + session: Session + startTime: float + progress: list[float] = field(default_factory=list) + endTime: float | None = None + + def setEndTime(self, newEndTime: float) -> None: + assert self.endTime is None, f"session already ended at {self.endTime}" + self.endTime = newEndTime + + @dataclass class TestUserInterface: """ @@ -52,6 +64,7 @@ class TestUserInterface: clock: IReactorTime actions: list[TestInterval] = field(default_factory=list) actualInterval: TestInterval | None = None + sessionChanges: list[SessionChange] = field(default_factory=list) def describeCurrentState(self, description: str) -> None: ... @@ -65,10 +78,12 @@ def intervalProgress(self, percentComplete: float) -> None: self.actualInterval.currentProgress.append(percentComplete) def sessionStarted(self, session: Session) -> None: - ... + self.sessionChanges.append( + SessionChange(session, self.clock.seconds()) + ) def sessionEnded(self) -> None: - ... + self.sessionChanges[-1].setEndTime(self.clock.seconds()) def intervalStart(self, interval: AnyIntervalOrIdle) -> None: """