Skip to content

Commit 7e0754d

Browse files
committed
add test cases
1 parent e1dfcc0 commit 7e0754d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

mergin/test/test_client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
decode_token_data,
2121
TokenError,
2222
ServerType,
23+
WorkspaceRole,
2324
)
2425
from ..client_push import push_project_async, push_project_cancel
2526
from ..client_pull import (
@@ -2886,3 +2887,24 @@ def test_mc_without_login():
28862887
# without login should not be able to access workspaces
28872888
with pytest.raises(ClientError, match="Authentication information is missing or invalid."):
28882889
mc.workspaces_list()
2890+
2891+
2892+
def test_do_request_error_handling(mc: MerginClient):
2893+
2894+
try:
2895+
mc.get("/v2/sso/connections?email=bad@email.com")
2896+
except ClientError as e:
2897+
assert e.http_error == 404
2898+
assert (
2899+
e.detail
2900+
== "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."
2901+
)
2902+
assert ": 404," in e.server_response
2903+
2904+
workspaces = mc.workspaces_list()
2905+
2906+
try:
2907+
mc.create_user("test@email.com", "123", workspace_id=workspaces[0]["id"], workspace_role=WorkspaceRole.GUEST)
2908+
except ClientError as e:
2909+
assert e.http_error == 400
2910+
assert "Passwords must be at least 8 characters long." in e.detail

0 commit comments

Comments
 (0)