cli2 3.3.34__tar.gz → 3.3.36__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.34/cli2.egg-info → cli2-3.3.36}/PKG-INFO +1 -1
- {cli2-3.3.34 → cli2-3.3.36}/cli2/client.py +3 -1
- {cli2-3.3.34 → cli2-3.3.36}/cli2/group.py +5 -3
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_client.py +17 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_group.py +8 -4
- {cli2-3.3.34 → cli2-3.3.36/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-3.3.34 → cli2-3.3.36}/setup.py +1 -1
- {cli2-3.3.34 → cli2-3.3.36}/MANIFEST.in +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/README.rst +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/classifiers.txt +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/__init__.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/argument.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/asyncio.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/cli.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/colors.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/command.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/configuration.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/decorators.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/display.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/entry_point.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/example_client.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/example_client_complex.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/example_nesting.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/example_obj.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/logging.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/node.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/overrides.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/sphinx.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/table.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_cli.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_command.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_configuration.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_decorators.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_display.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_entry_point.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_inject.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_node.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2/test_table.py +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2.egg-info/SOURCES.txt +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2.egg-info/requires.txt +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/cli2.egg-info/top_level.txt +0 -0
- {cli2-3.3.34 → cli2-3.3.36}/setup.cfg +0 -0
|
@@ -715,7 +715,9 @@ class ModelMetaclass(type):
|
|
|
715
715
|
client_class.models.append(cls)
|
|
716
716
|
client_cli = getattr(client_class, 'cli', None)
|
|
717
717
|
if client_cli:
|
|
718
|
-
|
|
718
|
+
group = ModelGroup(cls)
|
|
719
|
+
if len(group) > 1:
|
|
720
|
+
cls.cli = client_cli[cls.__name__.lower()] = group
|
|
719
721
|
|
|
720
722
|
cls._fields = dict()
|
|
721
723
|
|
|
@@ -188,11 +188,13 @@ class Group(EntryPoint, dict):
|
|
|
188
188
|
|
|
189
189
|
@cli2.cmd(condition=lambda cls: cls.url_list)
|
|
190
190
|
"""
|
|
191
|
-
|
|
191
|
+
final = leaf if leaf else cls
|
|
192
192
|
for base in cls.__bases__:
|
|
193
|
-
self.load_cls(base, leaf=
|
|
193
|
+
self.load_cls(base, leaf=final)
|
|
194
194
|
|
|
195
195
|
for name, method in cls.__dict__.items():
|
|
196
|
+
if leaf and getattr(final, name, '_') is None:
|
|
197
|
+
continue
|
|
196
198
|
wrapped_method = getattr(method, '__func__', None)
|
|
197
199
|
cfg = getattr(
|
|
198
200
|
wrapped_method,
|
|
@@ -203,7 +205,7 @@ class Group(EntryPoint, dict):
|
|
|
203
205
|
continue
|
|
204
206
|
condition = cfg.get('condition', None)
|
|
205
207
|
if condition:
|
|
206
|
-
if not condition(
|
|
208
|
+
if not condition(final):
|
|
207
209
|
continue
|
|
208
210
|
self.cmd(method)
|
|
209
211
|
|
|
@@ -51,6 +51,18 @@ async def test_client_cli(client_class, httpx_mock):
|
|
|
51
51
|
httpx_mock.add_response(url='http://lol/', json=[dict(a=1)])
|
|
52
52
|
await client_class.cli['testmodel']['find'].async_call()
|
|
53
53
|
|
|
54
|
+
class TestModel2(client_class.Model):
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
assert 'testmodel2' not in client_class.cli
|
|
58
|
+
|
|
59
|
+
class TestModel3(client_class.Model):
|
|
60
|
+
@cli2.cmd
|
|
61
|
+
def find():
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
assert list(client_class.cli['testmodel3'].keys()) == ['help', 'find']
|
|
65
|
+
|
|
54
66
|
|
|
55
67
|
@pytest.mark.asyncio
|
|
56
68
|
async def test_client_cli_override(client_class, httpx_mock):
|
|
@@ -77,6 +89,11 @@ async def test_client_cli_override(client_class, httpx_mock):
|
|
|
77
89
|
assert await Client.cli['testmodel2']['find'].async_call() == 'foo'
|
|
78
90
|
assert 'get' not in Client.cli['testmodel2']
|
|
79
91
|
|
|
92
|
+
class TestModel3(Client.Model):
|
|
93
|
+
url_list = '{client.test}/foo'
|
|
94
|
+
create = None
|
|
95
|
+
assert 'create' not in Client.cli['testmodel3']
|
|
96
|
+
|
|
80
97
|
|
|
81
98
|
def test_client_model(client_class):
|
|
82
99
|
assert issubclass(client_class.Model, cli2.Model)
|
|
@@ -230,7 +230,11 @@ def test_load_cls():
|
|
|
230
230
|
pass
|
|
231
231
|
group = Group()
|
|
232
232
|
group.load_cls(Foo)
|
|
233
|
-
assert '
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
assert list(group.keys()) == ['help', 'test', 'test2']
|
|
234
|
+
|
|
235
|
+
class Child(Foo):
|
|
236
|
+
test2 = None
|
|
237
|
+
|
|
238
|
+
group = Group()
|
|
239
|
+
group.load_cls(Child)
|
|
240
|
+
assert list(group.keys()) == ['help', 'test']
|
|
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
|