mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 12:51:25 -07:00
test/: PEP8 compliancy (#24803)
* test/: PEP8 compliancy - Make PEP8 compliant * Python3 chokes on casting int to bytes (#24952) But if we tell the formatter that the var is a number, it works
This commit is contained in:
parent
31c59ad5f9
commit
4efec414e7
110 changed files with 1702 additions and 1547 deletions
|
@ -436,10 +436,19 @@ class TestActionBase(unittest.TestCase):
|
|||
action_base._make_tmp_path.return_value = '/the/tmp/path'
|
||||
action_base._low_level_execute_command.return_value = dict(stdout='{"rc": 0, "stdout": "ok"}')
|
||||
self.assertEqual(action_base._execute_module(module_name=None, module_args=None), dict(_ansible_parsed=True, rc=0, stdout="ok", stdout_lines=['ok']))
|
||||
self.assertEqual(action_base._execute_module(module_name='foo',
|
||||
module_args=dict(z=9, y=8, x=7), task_vars=dict(a=1)),
|
||||
dict(_ansible_parsed=True, rc=0, stdout="ok",
|
||||
stdout_lines=['ok']))
|
||||
self.assertEqual(
|
||||
action_base._execute_module(
|
||||
module_name='foo',
|
||||
module_args=dict(z=9, y=8, x=7),
|
||||
task_vars=dict(a=1)
|
||||
),
|
||||
dict(
|
||||
_ansible_parsed=True,
|
||||
rc=0,
|
||||
stdout="ok",
|
||||
stdout_lines=['ok'],
|
||||
)
|
||||
)
|
||||
|
||||
# test with needing/removing a remote tmp path
|
||||
action_base._configure_module.return_value = ('old', '#!/usr/bin/python', 'this is the module data', 'path')
|
||||
|
@ -525,9 +534,9 @@ class TestActionBaseCleanReturnedData(unittest.TestCase):
|
|||
|
||||
mock_shared_loader_obj.connection_loader = mock_connection_loader
|
||||
mock_connection = MagicMock()
|
||||
#mock_connection._shell.env_prefix.side_effect = env_prefix
|
||||
# mock_connection._shell.env_prefix.side_effect = env_prefix
|
||||
|
||||
#action_base = DerivedActionBase(mock_task, mock_connection, play_context, None, None, None)
|
||||
# action_base = DerivedActionBase(mock_task, mock_connection, play_context, None, None, None)
|
||||
action_base = DerivedActionBase(task=None,
|
||||
connection=mock_connection,
|
||||
play_context=None,
|
||||
|
@ -535,7 +544,7 @@ class TestActionBaseCleanReturnedData(unittest.TestCase):
|
|||
templar=None,
|
||||
shared_loader_obj=mock_shared_loader_obj)
|
||||
data = {'ansible_playbook_python': '/usr/bin/python',
|
||||
#'ansible_rsync_path': '/usr/bin/rsync',
|
||||
# 'ansible_rsync_path': '/usr/bin/rsync',
|
||||
'ansible_python_interpreter': '/usr/bin/python',
|
||||
'ansible_ssh_some_var': 'whatever',
|
||||
'ansible_ssh_host_key_somehost': 'some key here',
|
||||
|
@ -592,7 +601,7 @@ class TestActionBaseParseReturnedData(unittest.TestCase):
|
|||
'stdout_lines': stdout.splitlines(),
|
||||
'stderr': err}
|
||||
res = action_base._parse_returned_data(returned_data)
|
||||
del res['_ansible_parsed'] # we always have _ansible_parsed
|
||||
del res['_ansible_parsed'] # we always have _ansible_parsed
|
||||
self.assertEqual(len(res), 0)
|
||||
self.assertFalse(res)
|
||||
|
||||
|
@ -610,7 +619,7 @@ class TestActionBaseParseReturnedData(unittest.TestCase):
|
|||
self.assertTrue(res['ansible_facts'])
|
||||
self.assertIn('ansible_blip', res['ansible_facts'])
|
||||
# TODO: Should this be an AnsibleUnsafe?
|
||||
#self.assertIsInstance(res['ansible_facts'], AnsibleUnsafe)
|
||||
# self.assertIsInstance(res['ansible_facts'], AnsibleUnsafe)
|
||||
|
||||
def test_json_facts_add_host(self):
|
||||
action_base = self._action_base()
|
||||
|
@ -630,4 +639,4 @@ class TestActionBaseParseReturnedData(unittest.TestCase):
|
|||
self.assertIn('ansible_blip', res['ansible_facts'])
|
||||
self.assertIn('add_host', res)
|
||||
# TODO: Should this be an AnsibleUnsafe?
|
||||
#self.assertIsInstance(res['ansible_facts'], AnsibleUnsafe)
|
||||
# self.assertIsInstance(res['ansible_facts'], AnsibleUnsafe)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue