DevPlace CI / test (push) Failing after 28m20s
Also streamline the top navigation: drop the Tools dropdown, make Quizzes and Battles icon-only entries, and remove the Workspace, Containers and Editor entry points from the project detail page.
33 lines
957 B
Python
33 lines
957 B
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from devplacepy.services import ai_modifier, correction
|
|
|
|
|
|
class _FakeResponse:
|
|
def __init__(self, content: str) -> None:
|
|
self._content = content
|
|
self.headers: dict = {}
|
|
|
|
def raise_for_status(self) -> None:
|
|
return None
|
|
|
|
def json(self) -> dict:
|
|
return {"choices": [{"message": {"content": self._content}}]}
|
|
|
|
|
|
class _FakeClient:
|
|
def __init__(self) -> None:
|
|
self.calls: list[dict] = []
|
|
|
|
def post(self, url, json=None, headers=None, timeout=None):
|
|
self.calls.append({"url": url, "json": json, "headers": headers})
|
|
return _FakeResponse("modified text")
|
|
|
|
|
|
def test_modify_text_requests_the_preamble_bypass(local_db, monkeypatch):
|
|
fake = _FakeClient()
|
|
monkeypatch.setattr(correction, "_client", lambda: fake)
|
|
ai_modifier.modify_text("user-api-key", "", "@ai fix this")
|
|
sent = fake.calls[-1]
|
|
assert sent["json"]["bypass_preamble"] is True
|