Added deal contract framework and testing documentation
This commit is contained in:
@@ -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]
|
||||
|
||||
9
pkgs/clan-cli/tests/test_with_deal.py
Normal file
9
pkgs/clan-cli/tests/test_with_deal.py
Normal 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()
|
||||
Reference in New Issue
Block a user