mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-12 20:45:20 +02:00
test: fix auth-mode mismatch and stale QuotaInsufficientError kwargs
Pin AUTH_TYPE=LOCAL (and REGISTRATION_ENABLED=TRUE) in the test bootstrap so the email/password auth routers mount during integration tests regardless of a developer's .env=GOOGLE; without this the upload tests 404 on registration. Also update three tests to the current QuotaInsufficientError signature (balance_micros) after used_micros/limit_micros were removed.
This commit is contained in:
parent
0808fbcdee
commit
99cf212c31
4 changed files with 11 additions and 6 deletions
|
|
@ -13,6 +13,14 @@ TEST_DATABASE_URL = os.environ.get("TEST_DATABASE_URL", _DEFAULT_TEST_DB)
|
|||
# DATABASE_URL in the environment (e.g. from .env or shell profile).
|
||||
os.environ["DATABASE_URL"] = TEST_DATABASE_URL
|
||||
|
||||
# Integration tests authenticate over HTTP via email/password, so the
|
||||
# password-auth routers must be mounted (they are skipped under AUTH_TYPE=GOOGLE).
|
||||
# setdefault (not load_dotenv, which runs later with override=False) lets a
|
||||
# developer's .env=GOOGLE be overridden here while still honouring an explicitly
|
||||
# exported shell AUTH_TYPE.
|
||||
os.environ.setdefault("AUTH_TYPE", "LOCAL")
|
||||
os.environ.setdefault("REGISTRATION_ENABLED", "TRUE")
|
||||
|
||||
import pytest # noqa: E402
|
||||
|
||||
from app.db import DocumentType # noqa: E402
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ async def test_quota_denial_fails_the_podcast_without_a_transcript(
|
|||
async def _deny(**_kwargs):
|
||||
raise QuotaInsufficientError(
|
||||
usage_type="podcast_generation",
|
||||
used_micros=5_000_000,
|
||||
limit_micros=5_000_000,
|
||||
balance_micros=0,
|
||||
remaining_micros=0,
|
||||
)
|
||||
yield # pragma: no cover - unreachable, satisfies the CM protocol
|
||||
|
|
|
|||
|
|
@ -105,8 +105,7 @@ async def test_ainvoke_propagates_quota_insufficient_error(monkeypatch):
|
|||
async def _denying_billable_call(**_kwargs):
|
||||
raise QuotaInsufficientError(
|
||||
usage_type="vision_extraction",
|
||||
used_micros=5_000_000,
|
||||
limit_micros=5_000_000,
|
||||
balance_micros=0,
|
||||
remaining_micros=0,
|
||||
)
|
||||
yield # unreachable but required for asynccontextmanager type
|
||||
|
|
|
|||
|
|
@ -98,8 +98,7 @@ async def _denying_billable_call(**kwargs):
|
|||
_CALL_LOG.append(kwargs)
|
||||
raise QuotaInsufficientError(
|
||||
usage_type=kwargs.get("usage_type", "?"),
|
||||
used_micros=5_000_000,
|
||||
limit_micros=5_000_000,
|
||||
balance_micros=0,
|
||||
remaining_micros=0,
|
||||
)
|
||||
yield SimpleNamespace() # pragma: no cover
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue