feat(api): add web wx-qr create and status endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-18 20:16:15 +08:00
1 parent 22634330d5
commit ec0045d5bf
2 files changed
+80

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
"""web wx-qr create/status API。"""
from unittest.mock import patch
import pytest
from fastapi.testclient import TestClient
from app.main import app
from app.services import wx_qr_session
client = TestClient(app)
@pytest.fixture(autouse=True)
def force_memory_backend(monkeypatch):
monkeypatch.setattr(wx_qr_session, "_redis", lambda: None)
wx_qr_session._memory_clear_for_tests()
def test_wx_qr_create_and_poll_pending():
with patch(
"app.api.public.get_unlimited_wxacode",
return_value=b"\x89PNG\r\n\x1a\n",
):
r = client.post("/api/web/auth/wx-qr/create")
assert r.status_code == 200
body = r.json()
assert body.get("code") == 200
data = body["data"]
sid = data["sessionId"]
assert data["qrImageBase64"].startswith("data:image/")
st = client.get("/api/web/auth/wx-qr/status", params={"sessionId": sid})
assert st.status_code == 200
assert st.json()["data"]["status"] == "pending"