fix(exception): 优化异常错误处理
This commit is contained in:
1 parent
2a036764e3
commit
14c5903aef
3 files changed
+24
-6
No files matched your search
@@ -100,8 +100,12 @@ def test_login_success(client):
|
||||
def test_login_fail(client):
|
||||
res = client.post('/api/user/login', json={'username': 'test1', 'password': 'wrongpassword'})
|
||||
assert res.status_code == 401
|
||||
assert 'Incorrect password' in res.get_json()['error']
|
||||
|
||||
body = res.get_json()
|
||||
assert body['error']['code'] == 'AUTH.INCORRECT_PASSWORD'
|
||||
assert 'Incorrect password' in body['error']['message']
|
||||
|
||||
res = client.post('/api/user/login', json={'username': 'nonexistent', 'password': 'password'})
|
||||
assert res.status_code == 404
|
||||
assert 'User not found' in res.get_json()['error']
|
||||
body = res.get_json()
|
||||
assert body['error']['code'] == 'AUTH.USER_NOT_FOUND'
|
||||
assert 'User not found' in body['error']['message']
|
||||
Reference in new issue
Block a user