refactor(backend): 重构后端
This commit is contained in:
1 parent
c8054476c1
commit
bba6e6f221
32 files changed
+252
-296
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from tests.conftest import flatten_api_error
|
||||
|
||||
from app import create_app, db
|
||||
from app.models import User
|
||||
from app.api import user as user_api
|
||||
@@ -77,7 +79,7 @@ def _start_input_verify_login(client, monkeypatch, *, userid, name='Test User',
|
||||
state = _issue_state(client)
|
||||
res = client.post('/api/user/wecom/login', json={'code': 'code-input-verify', 'state': state})
|
||||
assert res.status_code == 409
|
||||
data = res.get_json()
|
||||
data = flatten_api_error(res.get_json())
|
||||
assert data['error_code'] == 'WECOM_BIND_INPUT_REQUIRED'
|
||||
assert data['binding_token']
|
||||
return data
|
||||
@@ -164,7 +166,7 @@ def test_wecom_complete_bind_binds_user_by_selected_field(wecom_input_verify_cli
|
||||
'value': 'EMP001',
|
||||
})
|
||||
assert expired_res.status_code == 400
|
||||
assert expired_res.get_json()['error_code'] == 'WECOM_BIND_SESSION_EXPIRED'
|
||||
assert flatten_api_error(expired_res.get_json())['error_code'] == 'WECOM_BIND_SESSION_EXPIRED'
|
||||
|
||||
|
||||
def test_wecom_complete_bind_returns_not_found_when_value_does_not_match(wecom_input_verify_client, monkeypatch):
|
||||
@@ -198,7 +200,7 @@ def test_wecom_complete_bind_returns_not_found_when_value_does_not_match(wecom_i
|
||||
'value': 'missing@example.com',
|
||||
})
|
||||
assert bind_res.status_code == 404
|
||||
bind_data = bind_res.get_json()
|
||||
bind_data = flatten_api_error(bind_res.get_json())
|
||||
assert bind_data['error_code'] == 'WECOM_BIND_INPUT_NOT_FOUND'
|
||||
|
||||
|
||||
@@ -242,6 +244,6 @@ def test_wecom_complete_bind_returns_ambiguous_for_mobile_raw_and_normalized_dup
|
||||
'value': '+86 13800138000',
|
||||
})
|
||||
assert bind_res.status_code == 409
|
||||
bind_data = bind_res.get_json()
|
||||
bind_data = flatten_api_error(bind_res.get_json())
|
||||
assert bind_data['error_code'] == 'WECOM_BIND_INPUT_AMBIGUOUS'
|
||||
assert bind_data['candidate_count'] == 2
|
||||
Reference in new issue
Block a user