refactor(backend): 重构后端admin和schedule部分

This commit is contained in:
sophie committed 2026-07-01 13:34:29 +08:00
1 parent 9f5493185d
commit 4a14960e01
74 files changed
+5937 -3644

No files matched your search

+6 -6
View File
@@ -1,7 +1,7 @@
from app import db
from app.models import User
from app.api import admin as admin_api
from app.api import user as user_api
from app.services.auth import wecom_auth_service
from app.services.admin import wecom_admin_service
class DummyResponse:
@@ -37,7 +37,7 @@ def test_wecom_debug_user_by_code_returns_raw_user_and_match_preview(client, app
db.session.add(user)
db.session.commit()
monkeypatch.setattr(user_api, '_get_wecom_access_token', lambda: 'token-1')
monkeypatch.setattr(wecom_auth_service, 'get_access_token', lambda: 'token-1')
def fake_get(url, params=None, timeout=8):
if 'cgi-bin/auth/getuserinfo' in url:
@@ -52,7 +52,7 @@ def test_wecom_debug_user_by_code_returns_raw_user_and_match_preview(client, app
})
raise AssertionError(f'unexpected url: {url}')
monkeypatch.setattr(admin_api.requests, 'get', fake_get)
monkeypatch.setattr(wecom_admin_service.requests, 'get', fake_get)
res = client.post(
'/api/admin/wecom/debug-user-by-code',
@@ -76,14 +76,14 @@ def test_wecom_debug_user_by_code_returns_scope_error_when_only_openid(client, a
WECOM_SECRET='secret-test',
)
monkeypatch.setattr(user_api, '_get_wecom_access_token', lambda: 'token-1')
monkeypatch.setattr(wecom_auth_service, 'get_access_token', lambda: 'token-1')
def fake_get(url, params=None, timeout=8):
if 'cgi-bin/auth/getuserinfo' in url:
return DummyResponse({'errcode': 0, 'errmsg': 'ok', 'openid': 'oExternal_xx'})
raise AssertionError(f'unexpected url: {url}')
monkeypatch.setattr(admin_api.requests, 'get', fake_get)
monkeypatch.setattr(wecom_admin_service.requests, 'get', fake_get)
res = client.post(
'/api/admin/wecom/debug-user-by-code',