Skip to content

Commit

Permalink
record session changes
Browse files Browse the repository at this point in the history
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/.
  • Loading branch information
glyph committed Sep 12, 2024
1 parent 5e9e005 commit c39d93d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/pomodouroboros/model/test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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: ...

Expand All @@ -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:
"""
Expand Down

0 comments on commit c39d93d

Please sign in to comment.