cli2 4.0.1__tar.gz → 4.0.3__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-4.0.1/cli2.egg-info → cli2-4.0.3}/PKG-INFO +1 -1
- {cli2-4.0.1 → cli2-4.0.3}/cli2/ansible/action.py +4 -5
- {cli2-4.0.1 → cli2-4.0.3/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-4.0.1 → cli2-4.0.3}/setup.py +1 -1
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_ansible.py +19 -15
- {cli2-4.0.1 → cli2-4.0.3}/MANIFEST.in +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/README.rst +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/classifiers.txt +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/__init__.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/ansible/__init__.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/ansible/playbook.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/ansible/pytest.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/asyncio.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/cli.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/cli2.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/client.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/colors.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/configuration.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/decorators.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/display.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/__init__.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/client.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/conf.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/example.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/example_obj.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/nesting.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/obj.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/obj2.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/examples/test.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/lock.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/log.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/node.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/sphinx.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/table.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2/test.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2.egg-info/SOURCES.txt +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2.egg-info/requires.txt +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/cli2.egg-info/top_level.txt +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/setup.cfg +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_cli.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_client.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_command.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_configuration.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_decorators.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_display.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_entry_point.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_group.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_inject.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_lock.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_node.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_restful.py +0 -0
- {cli2-4.0.1 → cli2-4.0.3}/tests/test_table.py +0 -0
|
@@ -127,8 +127,8 @@ class ActionBase(ActionBase):
|
|
|
127
127
|
The client object generated by :py:meth:`client_factory` if you
|
|
128
128
|
implement it.
|
|
129
129
|
"""
|
|
130
|
-
def get(self, arg_name, fact_name=None, default=UNSET_DEFAULT):
|
|
131
|
-
if arg_name in self._task.args:
|
|
130
|
+
def get(self, arg_name=None, fact_name=None, default=UNSET_DEFAULT):
|
|
131
|
+
if arg_name and arg_name in self._task.args:
|
|
132
132
|
return self._task.args[arg_name]
|
|
133
133
|
if fact_name and fact_name in self.task_vars:
|
|
134
134
|
return self.task_vars[fact_name]
|
|
@@ -237,15 +237,14 @@ class ActionBase(ActionBase):
|
|
|
237
237
|
:param client: Client instance, overrides the factory
|
|
238
238
|
:param fail: Allow this test to fail without exception
|
|
239
239
|
"""
|
|
240
|
-
import mock
|
|
240
|
+
from unittest import mock
|
|
241
241
|
obj = cls(*[mock.Mock()] * 6)
|
|
242
242
|
obj.tmp = None
|
|
243
|
-
obj.task_vars = mock.Mock()
|
|
244
243
|
obj.result = dict()
|
|
245
244
|
obj._task = mock.Mock()
|
|
246
245
|
obj._task.args = args or {}
|
|
247
246
|
obj.task_vars = facts or {}
|
|
248
|
-
obj.task_vars
|
|
247
|
+
obj.task_vars.setdefault('ansible_verbosity', 2)
|
|
249
248
|
obj.exc = False
|
|
250
249
|
if client:
|
|
251
250
|
async def _factory():
|
|
@@ -39,30 +39,34 @@ async def test_response_error(httpx_mock):
|
|
|
39
39
|
@pytest.mark.asyncio
|
|
40
40
|
async def test_option():
|
|
41
41
|
class Action(ansible.ActionBase):
|
|
42
|
-
|
|
42
|
+
fact = ansible.Option(fact='fact', default='default fact')
|
|
43
|
+
arg = ansible.Option(arg='arg', fact='arg_fact')
|
|
43
44
|
|
|
44
45
|
async def run_async(self):
|
|
45
|
-
self.result['
|
|
46
|
-
|
|
47
|
-
module = await Action.run_test_async(args=dict(name='foo'))
|
|
48
|
-
assert module.result['name'] == 'foo'
|
|
46
|
+
self.result['arg'] = self.arg
|
|
47
|
+
self.result['fact'] = self.fact
|
|
49
48
|
|
|
50
|
-
module = await Action.run_test_async(facts=dict(object_name='foo'))
|
|
51
|
-
assert module.result['name'] == 'foo'
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
# test setting arg and fact
|
|
51
|
+
module = await Action.run_test_async(
|
|
52
|
+
args=dict(arg='arg'),
|
|
53
|
+
facts=dict(fact='fact'),
|
|
54
|
+
)
|
|
55
|
+
assert module.result['arg'] == 'arg'
|
|
56
|
+
assert module.result['fact'] == 'fact'
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
# test default
|
|
59
|
+
module = await Action.run_test_async(
|
|
60
|
+
args=dict(arg='arg'),
|
|
61
|
+
)
|
|
62
|
+
assert module.result['arg'] == 'arg'
|
|
63
|
+
assert module.result['fact'] == 'default fact'
|
|
61
64
|
|
|
65
|
+
# test failing for missing default
|
|
62
66
|
module = await Action.run_test_async(fail=True)
|
|
63
67
|
assert module.result == dict(
|
|
64
68
|
failed=True,
|
|
65
|
-
error="Missing arg `
|
|
69
|
+
error="Missing arg `arg` or fact `arg_fact`",
|
|
66
70
|
)
|
|
67
71
|
|
|
68
72
|
class Action(ansible.ActionBase):
|
|
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
|
|
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
|