cli2 3.3.36__tar.gz → 3.3.37__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.
Files changed (45) hide show
  1. {cli2-3.3.36/cli2.egg-info → cli2-3.3.37}/PKG-INFO +1 -1
  2. {cli2-3.3.36 → cli2-3.3.37}/cli2/client.py +3 -1
  3. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_client.py +43 -0
  4. {cli2-3.3.36 → cli2-3.3.37/cli2.egg-info}/PKG-INFO +1 -1
  5. {cli2-3.3.36 → cli2-3.3.37}/setup.py +1 -1
  6. {cli2-3.3.36 → cli2-3.3.37}/MANIFEST.in +0 -0
  7. {cli2-3.3.36 → cli2-3.3.37}/README.rst +0 -0
  8. {cli2-3.3.36 → cli2-3.3.37}/classifiers.txt +0 -0
  9. {cli2-3.3.36 → cli2-3.3.37}/cli2/__init__.py +0 -0
  10. {cli2-3.3.36 → cli2-3.3.37}/cli2/argument.py +0 -0
  11. {cli2-3.3.36 → cli2-3.3.37}/cli2/asyncio.py +0 -0
  12. {cli2-3.3.36 → cli2-3.3.37}/cli2/cli.py +0 -0
  13. {cli2-3.3.36 → cli2-3.3.37}/cli2/colors.py +0 -0
  14. {cli2-3.3.36 → cli2-3.3.37}/cli2/command.py +0 -0
  15. {cli2-3.3.36 → cli2-3.3.37}/cli2/configuration.py +0 -0
  16. {cli2-3.3.36 → cli2-3.3.37}/cli2/decorators.py +0 -0
  17. {cli2-3.3.36 → cli2-3.3.37}/cli2/display.py +0 -0
  18. {cli2-3.3.36 → cli2-3.3.37}/cli2/entry_point.py +0 -0
  19. {cli2-3.3.36 → cli2-3.3.37}/cli2/example_client.py +0 -0
  20. {cli2-3.3.36 → cli2-3.3.37}/cli2/example_client_complex.py +0 -0
  21. {cli2-3.3.36 → cli2-3.3.37}/cli2/example_nesting.py +0 -0
  22. {cli2-3.3.36 → cli2-3.3.37}/cli2/example_obj.py +0 -0
  23. {cli2-3.3.36 → cli2-3.3.37}/cli2/group.py +0 -0
  24. {cli2-3.3.36 → cli2-3.3.37}/cli2/logging.py +0 -0
  25. {cli2-3.3.36 → cli2-3.3.37}/cli2/node.py +0 -0
  26. {cli2-3.3.36 → cli2-3.3.37}/cli2/overrides.py +0 -0
  27. {cli2-3.3.36 → cli2-3.3.37}/cli2/sphinx.py +0 -0
  28. {cli2-3.3.36 → cli2-3.3.37}/cli2/table.py +0 -0
  29. {cli2-3.3.36 → cli2-3.3.37}/cli2/test.py +0 -0
  30. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_cli.py +0 -0
  31. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_command.py +0 -0
  32. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_configuration.py +0 -0
  33. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_decorators.py +0 -0
  34. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_display.py +0 -0
  35. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_entry_point.py +0 -0
  36. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_group.py +0 -0
  37. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_inject.py +0 -0
  38. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_node.py +0 -0
  39. {cli2-3.3.36 → cli2-3.3.37}/cli2/test_table.py +0 -0
  40. {cli2-3.3.36 → cli2-3.3.37}/cli2.egg-info/SOURCES.txt +0 -0
  41. {cli2-3.3.36 → cli2-3.3.37}/cli2.egg-info/dependency_links.txt +0 -0
  42. {cli2-3.3.36 → cli2-3.3.37}/cli2.egg-info/entry_points.txt +0 -0
  43. {cli2-3.3.36 → cli2-3.3.37}/cli2.egg-info/requires.txt +0 -0
  44. {cli2-3.3.36 → cli2-3.3.37}/cli2.egg-info/top_level.txt +0 -0
  45. {cli2-3.3.36 → cli2-3.3.37}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cli2
3
- Version: 3.3.36
3
+ Version: 3.3.37
4
4
  Summary: image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
5
5
  Home-page: https://yourlabs.io/oss/cli2
6
6
  Author: James Pic
@@ -708,6 +708,8 @@ class ModelMetaclass(type):
708
708
  cls = super().__new__(cls, name, bases, attributes)
709
709
  client = getattr(cls, 'client', None)
710
710
  if client:
711
+ if not cls.paginator:
712
+ cls.paginator = client.paginator
711
713
  return cls
712
714
 
713
715
  client_class = getattr(cls, '_client_class', None)
@@ -776,7 +778,7 @@ class Model(metaclass=ModelMetaclass):
776
778
 
777
779
  Object URL based on :py:attr:`url_detail` and :py:attr:`id_field`.
778
780
  """
779
- paginator = Paginator
781
+ paginator = None
780
782
  model_command = ModelCommand
781
783
  model_group = ModelGroup
782
784
  url_list = None
@@ -389,6 +389,21 @@ async def test_pagination(httpx_mock):
389
389
  ]
390
390
 
391
391
 
392
+ def test_paginator(client_class):
393
+ class Client(client_class):
394
+ paginator = 'foo'
395
+
396
+ class Model1(Client.Model):
397
+ pass
398
+
399
+ class Model2(Client.Model):
400
+ paginator = 'bar'
401
+
402
+ client = Client()
403
+ assert client.Model1.paginator == 'foo'
404
+ assert client.Model2.paginator == 'bar'
405
+
406
+
392
407
  @pytest.mark.asyncio
393
408
  async def test_pagination_initialize(httpx_mock):
394
409
  httpx_mock.add_response(url='http://lol/?page=1', json=dict(
@@ -515,6 +530,34 @@ async def test_pagination_patterns(httpx_mock):
515
530
  assert paginator.per_page == 1
516
531
  assert paginator.pagination_parameters(2) == dict(offset=1, limit=1)
517
532
 
533
+ class Key(Client.Model):
534
+ url_list = '/key'
535
+
536
+ @classmethod
537
+ def pagination_initialize(cls, paginator, data):
538
+ paginator.next_page = data['next_page']
539
+ paginator.total_pages = data['total']
540
+
541
+ @classmethod
542
+ def pagination_parameters(cls, paginator, page_number):
543
+ if page_number > 1:
544
+ return dict(next_page=paginator.next_page)
545
+
546
+ httpx_mock.add_response(
547
+ url='http://lol/key',
548
+ json=dict(total=2, items=[dict(a=1)], next_page='aoeu'),
549
+ )
550
+ httpx_mock.add_response(
551
+ url='http://lol/key?next_page=aoeu',
552
+ json=dict(total=2, items=[dict(a=2)]),
553
+ )
554
+
555
+ client = Client(base_url='http://lol')
556
+ items = []
557
+ async for item in client.Key.find():
558
+ items.append(item.data['a'])
559
+ assert items == [1, 2]
560
+
518
561
 
519
562
  @pytest.mark.asyncio
520
563
  async def test_pagination_reverse(httpx_mock):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cli2
3
- Version: 3.3.36
3
+ Version: 3.3.37
4
4
  Summary: image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
5
5
  Home-page: https://yourlabs.io/oss/cli2
6
6
  Author: James Pic
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name='cli2',
6
- version='3.3.36',
6
+ version='3.3.37',
7
7
  setup_requires='setupmeta',
8
8
  install_requires=[
9
9
  'docstring_parser',
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