cli2 3.3.44__tar.gz → 3.3.46__tar.gz
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.
- {cli2-3.3.44/cli2.egg-info → cli2-3.3.46}/PKG-INFO +1 -1
- {cli2-3.3.44 → cli2-3.3.46}/cli2/client.py +11 -15
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_client.py +9 -9
- {cli2-3.3.44 → cli2-3.3.46/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-3.3.44 → cli2-3.3.46}/setup.py +1 -1
- {cli2-3.3.44 → cli2-3.3.46}/MANIFEST.in +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/README.rst +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/classifiers.txt +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/__init__.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/argument.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/asyncio.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/cli.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/colors.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/command.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/configuration.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/decorators.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/display.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/entry_point.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/example_client.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/example_client_complex.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/example_nesting.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/example_obj.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/group.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/logging.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/node.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/overrides.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/sphinx.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/table.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_cli.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_command.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_configuration.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_decorators.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_display.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_entry_point.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_group.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_inject.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_node.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2/test_table.py +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2.egg-info/SOURCES.txt +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2.egg-info/requires.txt +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/cli2.egg-info/top_level.txt +0 -0
- {cli2-3.3.44 → cli2-3.3.46}/setup.cfg +0 -0
|
@@ -168,7 +168,7 @@ class Paginator:
|
|
|
168
168
|
:param data: Data of the first response
|
|
169
169
|
"""
|
|
170
170
|
|
|
171
|
-
def pagination_parameters(self, page_number):
|
|
171
|
+
def pagination_parameters(self, params, page_number):
|
|
172
172
|
"""
|
|
173
173
|
Return GET parameters for a given page.
|
|
174
174
|
|
|
@@ -180,12 +180,15 @@ class Paginator:
|
|
|
180
180
|
|
|
181
181
|
.. code-block:: python
|
|
182
182
|
|
|
183
|
-
def pagination_parameters(self, page_number):
|
|
183
|
+
def pagination_parameters(self, params, page_number):
|
|
184
184
|
# this is the default implementation
|
|
185
|
-
|
|
185
|
+
params['page'] = page_number
|
|
186
|
+
|
|
187
|
+
:param params: Dict of base GET parameters
|
|
188
|
+
:param page_number: Page number to get
|
|
186
189
|
"""
|
|
187
190
|
if page_number > 1:
|
|
188
|
-
|
|
191
|
+
params['page'] = page_number
|
|
189
192
|
|
|
190
193
|
def response_items(self, response):
|
|
191
194
|
"""
|
|
@@ -228,10 +231,7 @@ class Paginator:
|
|
|
228
231
|
|
|
229
232
|
:param page_number: Page number to get the items from
|
|
230
233
|
"""
|
|
231
|
-
|
|
232
|
-
return self.response_items(await self.page_response(page_number))
|
|
233
|
-
except NotImplementedError:
|
|
234
|
-
return []
|
|
234
|
+
return self.response_items(await self.page_response(page_number))
|
|
235
235
|
|
|
236
236
|
async def page_response(self, page_number):
|
|
237
237
|
"""
|
|
@@ -240,13 +240,7 @@ class Paginator:
|
|
|
240
240
|
:param page_number: Page number to get the items from
|
|
241
241
|
"""
|
|
242
242
|
params = self.params.copy()
|
|
243
|
-
|
|
244
|
-
if pagination_parameters:
|
|
245
|
-
params.update(pagination_parameters)
|
|
246
|
-
elif page_number != 1:
|
|
247
|
-
raise NotImplementedError(
|
|
248
|
-
'pagination_parameters returned None, cannot paginate',
|
|
249
|
-
)
|
|
243
|
+
self.pagination_parameters(params, page_number)
|
|
250
244
|
for expression in self.expressions:
|
|
251
245
|
if expression.parameterable:
|
|
252
246
|
expression.params(params)
|
|
@@ -533,6 +527,8 @@ class JSONStringField(MutableField):
|
|
|
533
527
|
return json.dumps(data, **self.options)
|
|
534
528
|
|
|
535
529
|
def externalize(self, obj, value):
|
|
530
|
+
if value == '':
|
|
531
|
+
return value
|
|
536
532
|
return json.loads(value)
|
|
537
533
|
|
|
538
534
|
|
|
@@ -162,9 +162,6 @@ class Client(cli2.Client):
|
|
|
162
162
|
kwargs.setdefault('base_url', 'http://lol')
|
|
163
163
|
super().__init__(*args, **kwargs)
|
|
164
164
|
|
|
165
|
-
def pagination_parameters(self, paginator, page_number):
|
|
166
|
-
return dict(page=page_number)
|
|
167
|
-
|
|
168
165
|
|
|
169
166
|
raised = False
|
|
170
167
|
|
|
@@ -499,12 +496,10 @@ async def test_pagination_patterns(httpx_mock):
|
|
|
499
496
|
def pagination_initialize(self, data):
|
|
500
497
|
self.total_items = data['total']
|
|
501
498
|
|
|
502
|
-
def pagination_parameters(self, page_number):
|
|
499
|
+
def pagination_parameters(self, params, page_number):
|
|
503
500
|
self.per_page = 1
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
limit=paginator.per_page,
|
|
507
|
-
)
|
|
501
|
+
params['offset'] = (page_number - 1) * self.per_page
|
|
502
|
+
params['limit'] = self.per_page
|
|
508
503
|
|
|
509
504
|
class Offset(Client.Model):
|
|
510
505
|
url_list = '/off'
|
|
@@ -532,7 +527,9 @@ async def test_pagination_patterns(httpx_mock):
|
|
|
532
527
|
await paginator.initialize()
|
|
533
528
|
assert paginator.total_pages == 2
|
|
534
529
|
assert paginator.per_page == 1
|
|
535
|
-
|
|
530
|
+
params = dict()
|
|
531
|
+
paginator.pagination_parameters(params, 2)
|
|
532
|
+
assert params == dict(offset=1, limit=1)
|
|
536
533
|
|
|
537
534
|
|
|
538
535
|
@pytest.mark.asyncio
|
|
@@ -612,6 +609,9 @@ def test_jsonstring():
|
|
|
612
609
|
model.json = dict(a=1)
|
|
613
610
|
assert model.data['json'] == '{"a": 1}'
|
|
614
611
|
|
|
612
|
+
model = client.Model(data=dict(json=''))
|
|
613
|
+
assert model.json == ''
|
|
614
|
+
|
|
615
615
|
|
|
616
616
|
def test_datetime():
|
|
617
617
|
class Model(Client.Model):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|