fix: address PR #5 review comments
- Add class-level type annotations on TrelloClient (api_key, token, _session) - Add TypedDict response contracts with TypeGuard narrowing for _request - Replace os.environ manipulation with monkeypatch in tests - Align disconnect message with auto-reconnect behavior - Add docstring for TRELLO_API_BASE constant - Add _post and _put request helpers for future endpoints
This commit is contained in:
+4
-8
@@ -8,6 +8,7 @@ from collections.abc import Generator
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from pytest import MonkeyPatch
|
||||
import requests
|
||||
|
||||
# Tell pytest we plan to set env vars in tests
|
||||
@@ -19,16 +20,11 @@ pytestmark = pytest.mark.usefixtures("clear_env")
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clear_env() -> Generator[None, None, None]:
|
||||
def clear_env(monkeypatch: MonkeyPatch) -> Generator[None, None, None]:
|
||||
"""Remove Trello env vars before each test so state is predictable."""
|
||||
# Use monkeypatch via request directly — fallback to os.environ
|
||||
saved_key = os.environ.pop("TRELLO_API_KEY", None)
|
||||
saved_token = os.environ.pop("TRELLO_TOKEN", None)
|
||||
monkeypatch.delenv("TRELLO_API_KEY", raising=False)
|
||||
monkeypatch.delenv("TRELLO_TOKEN", raising=False)
|
||||
yield
|
||||
if saved_key is not None:
|
||||
os.environ["TRELLO_API_KEY"] = saved_key
|
||||
if saved_token is not None:
|
||||
os.environ["TRELLO_TOKEN"] = saved_token
|
||||
|
||||
|
||||
def _make_session(mocker: Any) -> requests.Session:
|
||||
|
||||
Reference in New Issue
Block a user