-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_delete.py
More file actions
106 lines (94 loc) · 2.57 KB
/
test_delete.py
File metadata and controls
106 lines (94 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import json
from scim2_cli import cli
def test_nominal_case(runner, httpserver):
"""Test deletion nominal case."""
httpserver.expect_request(
"/Users/ok",
method="DELETE",
).respond_with_data(
"",
status=204,
content_type="application/scim+json",
)
result = runner.invoke(
cli,
[
"--url",
httpserver.url_for("/"),
"delete",
"user",
"ok",
],
catch_exceptions=False,
)
assert result.exit_code == 0, result.output
def test_scimclient_error(runner, httpserver):
"""Test scim2_client errors handling."""
httpserver.expect_request(
"/Users/dummy-id",
method="DELETE",
).respond_with_data(
"",
status=999,
content_type="application/scim+json",
)
result = runner.invoke(
cli,
[
"--url",
httpserver.url_for("/"),
"delete",
"user",
"dummy-id",
],
catch_exceptions=False,
)
assert result.exit_code == 1, result.output
assert "Unexpected response status code: 999" in result.output
def test_bad_resource_type(runner, httpserver):
"""Test passing an unknown resource type."""
result = runner.invoke(
cli,
[
"--url",
httpserver.url_for("/"),
"delete",
"invalid",
"dummy-id",
],
catch_exceptions=False,
)
assert result.exit_code == 1, result.output
assert "Unknown resource type 'invalid'." in result.output
def test_not_found(runner, httpserver):
"""Test pydantic errors handling."""
httpserver.expect_request(
"/Users/unknown-id",
method="DELETE",
).respond_with_json(
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
"detail": "Resource 2819c223-7f76-453a-919d-413861904646 not found",
"status": "404",
},
status=404,
content_type="application/scim+json",
)
result = runner.invoke(
cli,
[
"--url",
httpserver.url_for("/"),
"delete",
"user",
"unknown-id",
],
catch_exceptions=False,
)
assert result.exit_code == 0, result.output
json_output = json.loads(result.output)
assert json_output == {
"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
"detail": "Resource 2819c223-7f76-453a-919d-413861904646 not found",
"status": "404",
}