casebench
test cases straight onto the board.
git clone https://owenrusk.dev/casebench.git
casebench / casebench/store.py -rw-r--r-- · 1281 bytes
1 from dataclasses import dataclass 2 from datetime import datetime 3 from typing import Protocol 4 5 from .casefile import Case 6 from .lock import Lock 7 8 BENCH = "bench" 9 10 11 @dataclass(frozen=True) 12 class Player: 13 id: str 14 handle: str 15 16 17 @dataclass(frozen=True) 18 class Placed: 19 case_id: str 20 title: str 21 source: str 22 placed_at: datetime 23 lock: str | None = None # locked, resting or open 24 notes: int = 0 25 26 27 class Store(Protocol): 28 # everything casebench reads or writes on the board goes through here. 29 30 def players(self) -> list[Player]: ... 31 32 def player(self, handle: str) -> Player | None: ... 33 34 def placed(self, player: Player, case_id: str) -> Placed | None: ... 35 36 def board(self, player: Player) -> list[Placed]: ... 37 38 def items(self, player: Player, case_id: str) -> list[str]: ... 39 40 def put(self, player: Player, case: Case) -> None: ... 41 42 def pull(self, player: Player, case_id: str) -> None: ... 43 44 def note(self, player: Player, case_id: str, item_id: str | None, text: str) -> None: ... 45 46 def lock(self, player: Player, case_id: str, new: Lock) -> None: ... 47 48 def get_lock(self, player: Player, case_id: str) -> Lock | None: ... 49 50 def unlock(self, player: Player, case_id: str) -> bool: ... 51 52 def close(self) -> None: ...