Files
python-learning/exercises/02-engineering-2026/04-testing-best-practices/testing_ex.py
T

26 lines
729 B
Python

from typing import Protocol
class KvStore(Protocol):
def get(self, key: str) -> str | None: ...
def set(self, key: str, value: str) -> None: ...
class InMemoryKvStore:
def __init__(self) -> None:
self._data: dict[str, str] = {}
def get(self, key: str) -> str | None:
raise NotImplementedError("Pobierz wartość lub None")
def set(self, key: str, value: str) -> None:
raise NotImplementedError("Zapisz wartość w słowniku")
class FeatureFlagService:
def __init__(self, store: KvStore) -> None:
self._store = store
def is_enabled(self, flag: str) -> bool:
raise NotImplementedError("Zwróć True jeśli wartość flagi to 'true' lub '1' (lowercase)")