Added deal contract framework and testing documentation

This commit is contained in:
Qubasa
2023-11-08 19:50:31 +01:00
parent 32aa287da5
commit 7240727b26
6 changed files with 160 additions and 18 deletions

View File

@@ -12,6 +12,8 @@ from pathlib import Path
from typing import Any, Iterator, Optional, Type, TypeVar
from uuid import UUID, uuid4
import deal
from .custom_logger import ThreadFormatter, get_caller
from .errors import ClanError
@@ -161,6 +163,8 @@ class TaskPool:
def __getitem__(self, uuid: UUID) -> BaseTask:
with self.lock:
if uuid not in self.pool:
raise ClanError(f"Task with uuid {uuid} does not exist")
return self.pool[uuid]
def __setitem__(self, uuid: UUID, task: BaseTask) -> None:
@@ -175,6 +179,7 @@ class TaskPool:
POOL: TaskPool = TaskPool()
@deal.raises(ClanError)
def get_task(uuid: UUID) -> BaseTask:
global POOL
return POOL[uuid]

View File

@@ -0,0 +1,9 @@
import deal
from clan_cli.task_manager import get_task
# type annotations below are optional
@deal.cases(get_task)
def test_get_task(case: deal.TestCase) -> None:
case()