refactor
This commit is contained in:
parent
7cef56de15
commit
ecb5f68e32
17 changed files with 760 additions and 1626 deletions
|
|
@ -11,11 +11,9 @@ class StubManager(AccountManager):
|
|||
def __init__(
|
||||
self,
|
||||
response: dict[str, Any] | None = None,
|
||||
usage_response: dict[str, Any] | None = None,
|
||||
error: Exception | None = None,
|
||||
):
|
||||
self.response = response
|
||||
self.usage_response = usage_response
|
||||
self.error = error
|
||||
|
||||
async def issue_token_response(self):
|
||||
|
|
@ -25,12 +23,6 @@ class StubManager(AccountManager):
|
|||
return self.response
|
||||
return {}
|
||||
|
||||
async def get_usage_report(self):
|
||||
if self.usage_response is not None:
|
||||
return self.usage_response
|
||||
return {"accounts": [], "active_account_id": None, "count": 0}
|
||||
|
||||
|
||||
def test_health_ok() -> None:
|
||||
client = TestClient(create_app(StubManager(response={})))
|
||||
response = client.get("/health")
|
||||
|
|
@ -64,26 +56,3 @@ def test_token_error_shape() -> None:
|
|||
response = client.get("/token")
|
||||
assert response.status_code == 503
|
||||
assert response.json() == {"error": "No usable account available"}
|
||||
|
||||
|
||||
def test_usage_success_shape() -> None:
|
||||
payload = {
|
||||
"accounts": [
|
||||
{
|
||||
"id": "a1",
|
||||
"email": "a1@example.com",
|
||||
"status": "ok",
|
||||
"used_percent": 12,
|
||||
"remaining_percent": 88,
|
||||
"cooldown_until": None,
|
||||
"primary_window": {"used_percent": 12},
|
||||
"secondary_window": {"used_percent": 1},
|
||||
}
|
||||
],
|
||||
"active_account_id": "a1",
|
||||
"count": 1,
|
||||
}
|
||||
client = TestClient(create_app(StubManager(usage_response=payload)))
|
||||
response = client.get("/usage")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == payload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue