scim2-client 0.4.3__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,8 +37,10 @@ class TestSCIMClient(BaseSyncSCIMClient):
37
37
  This client avoids to perform real HTTP requests and directly execute the server code instead.
38
38
  This allows to dynamically catch the exceptions if something gets wrong.
39
39
 
40
- :param client: A WSGI application instance that will be used to send requests.
40
+ :param client: An optional custom :class:`Werkzeug test Client <werkzeug.test.Client>`.
41
+ If :data:`None` a default client is initialized.
41
42
  :param scim_prefix: The scim root endpoint in the application.
43
+ :param environ: Additional parameters that will be passed to every request.
42
44
  :param resource_models: A tuple of :class:`~scim2_models.Resource` types expected to be handled by the SCIM client.
43
45
  If a request payload describe a resource that is not in this list, an exception will be raised.
44
46
  :param check_request_payload: If :data:`False`,
@@ -54,9 +56,14 @@ class TestSCIMClient(BaseSyncSCIMClient):
54
56
 
55
57
  from scim2_client.engines.werkzeug import TestSCIMClient
56
58
  from scim2_models import User, Group
59
+ from werkzeug.test import Client
57
60
 
58
61
  scim_provider = myapp.create_app()
59
- testclient = TestSCIMClient(app=scim_provider, resource_models=(User, Group))
62
+ testclient = TestSCIMClient(
63
+ app=Client(scim_provider),
64
+ environ={"base_url": "/scim/v2"},
65
+ resource_models=(User, Group),
66
+ )
60
67
 
61
68
  request_user = User(user_name="foo", display_name="bar")
62
69
  response_user = scim_client.create(request_user)
@@ -66,10 +73,18 @@ class TestSCIMClient(BaseSyncSCIMClient):
66
73
  # avoid making Pytest believe this is a test class
67
74
  __test__ = False
68
75
 
69
- def __init__(self, app, *args, scim_prefix: str = "", **kwargs):
76
+ def __init__(
77
+ self,
78
+ client: Client,
79
+ environ: Optional[dict] = None,
80
+ scim_prefix: str = "",
81
+ *args,
82
+ **kwargs,
83
+ ):
70
84
  super().__init__(*args, **kwargs)
71
- self.client = Client(app)
85
+ self.client = client
72
86
  self.scim_prefix = scim_prefix
87
+ self.environ = environ or {}
73
88
 
74
89
  def make_url(self, url: Optional[str]) -> str:
75
90
  url = url or ""
@@ -103,9 +118,8 @@ class TestSCIMClient(BaseSyncSCIMClient):
103
118
  **kwargs,
104
119
  )
105
120
 
106
- response = self.client.post(
107
- self.make_url(req.url), json=req.payload, **req.request_kwargs
108
- )
121
+ environ = {**self.environ, **req.request_kwargs}
122
+ response = self.client.post(self.make_url(req.url), json=req.payload, **environ)
109
123
 
110
124
  with handle_response_error(req.payload):
111
125
  return self.check_response(
@@ -143,8 +157,9 @@ class TestSCIMClient(BaseSyncSCIMClient):
143
157
  )
144
158
 
145
159
  query_string = urlencode(req.payload, doseq=False) if req.payload else None
160
+ environ = {**self.environ, **req.request_kwargs}
146
161
  response = self.client.get(
147
- self.make_url(req.url), query_string=query_string, **req.request_kwargs
162
+ self.make_url(req.url), query_string=query_string, **environ
148
163
  )
149
164
 
150
165
  with handle_response_error(req.payload):
@@ -178,9 +193,8 @@ class TestSCIMClient(BaseSyncSCIMClient):
178
193
  **kwargs,
179
194
  )
180
195
 
181
- response = self.client.post(
182
- self.make_url(req.url), json=req.payload, **req.request_kwargs
183
- )
196
+ environ = {**self.environ, **req.request_kwargs}
197
+ response = self.client.post(self.make_url(req.url), json=req.payload, **environ)
184
198
 
185
199
  with handle_response_error(response):
186
200
  return self.check_response(
@@ -213,7 +227,8 @@ class TestSCIMClient(BaseSyncSCIMClient):
213
227
  **kwargs,
214
228
  )
215
229
 
216
- response = self.client.delete(self.make_url(req.url), **req.request_kwargs)
230
+ environ = {**self.environ, **req.request_kwargs}
231
+ response = self.client.delete(self.make_url(req.url), **environ)
217
232
 
218
233
  with handle_response_error(response):
219
234
  return self.check_response(
@@ -244,9 +259,8 @@ class TestSCIMClient(BaseSyncSCIMClient):
244
259
  **kwargs,
245
260
  )
246
261
 
247
- response = self.client.put(
248
- self.make_url(req.url), json=req.payload, **req.request_kwargs
249
- )
262
+ environ = {**self.environ, **req.request_kwargs}
263
+ response = self.client.put(self.make_url(req.url), json=req.payload, **environ)
250
264
 
251
265
  with handle_response_error(response):
252
266
  return self.check_response(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: scim2-client
3
- Version: 0.4.3
3
+ Version: 0.5.0
4
4
  Summary: Pythonically build SCIM requests and parse SCIM responses
5
5
  Project-URL: documentation, https://scim2-client.readthedocs.io
6
6
  Project-URL: repository, https://github.com/python-scim/scim2-client
@@ -4,8 +4,8 @@ scim2_client/errors.py,sha256=FVmRXsaZLn1VZhJ3dSDs4IqycuU92AEun9JWWMseVO8,4397
4
4
  scim2_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  scim2_client/engines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  scim2_client/engines/httpx.py,sha256=L39ZZHjqe43uIQpgh_r_maqM2gkf3_Rk6d8MeNe57gk,17781
7
- scim2_client/engines/werkzeug.py,sha256=mVpK0GjmD4fu0jI0W2zqrn7GjBFZ0AjNk2gBO5415Gk,10230
8
- scim2_client-0.4.3.dist-info/METADATA,sha256=YHWHLDbgqOKPjlVU6Ab-WEFrCZOrXnVrzixgZ4_6kzw,16961
9
- scim2_client-0.4.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
10
- scim2_client-0.4.3.dist-info/licenses/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
- scim2_client-0.4.3.dist-info/RECORD,,
7
+ scim2_client/engines/werkzeug.py,sha256=DmUBWytoWPehcrgBpGzlRJLCT7mrAW_VWSQ6BHylwCo,10800
8
+ scim2_client-0.5.0.dist-info/METADATA,sha256=e9pWKfSXOIVsyRptG9Eg34SAgn_alcz2DDbGr9PaEIQ,16961
9
+ scim2_client-0.5.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
10
+ scim2_client-0.5.0.dist-info/licenses/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
+ scim2_client-0.5.0.dist-info/RECORD,,