mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
PEP 8 indent cleanup. (#20800)
* PEP 8 E121 cleanup. * PEP 8 E126 cleanup. * PEP 8 E122 cleanup.
This commit is contained in:
parent
1c6bb4add9
commit
10d9318de7
244 changed files with 2873 additions and 2973 deletions
|
@ -92,28 +92,28 @@ class TestAnsibleModuleExitJson(unittest.TestCase):
|
|||
class TestAnsibleModuleExitValuesRemoved(unittest.TestCase):
|
||||
OMIT = 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
|
||||
dataset = (
|
||||
(dict(username='person', password='$ecret k3y'),
|
||||
(dict(username='person', password='$ecret k3y'),
|
||||
dict(one=1, pwd='$ecret k3y', url='https://username:password12345@foo.com/login/',
|
||||
not_secret='following the leader', msg='here'),
|
||||
dict(one=1, pwd=OMIT, url='https://username:password12345@foo.com/login/',
|
||||
not_secret='following the leader', changed=False, msg='here',
|
||||
invocation=dict(module_args=dict(password=OMIT, token=None, username='person'))),
|
||||
),
|
||||
(dict(username='person', password='password12345'),
|
||||
(dict(username='person', password='password12345'),
|
||||
dict(one=1, pwd='$ecret k3y', url='https://username:password12345@foo.com/login/',
|
||||
not_secret='following the leader', msg='here'),
|
||||
dict(one=1, pwd='$ecret k3y', url='https://username:********@foo.com/login/',
|
||||
not_secret='following the leader', changed=False, msg='here',
|
||||
invocation=dict(module_args=dict(password=OMIT, token=None, username='person'))),
|
||||
),
|
||||
(dict(username='person', password='$ecret k3y'),
|
||||
(dict(username='person', password='$ecret k3y'),
|
||||
dict(one=1, pwd='$ecret k3y', url='https://username:$ecret k3y@foo.com/login/',
|
||||
not_secret='following the leader', msg='here'),
|
||||
dict(one=1, pwd=OMIT, url='https://username:********@foo.com/login/',
|
||||
not_secret='following the leader', changed=False, msg='here',
|
||||
invocation=dict(module_args=dict(password=OMIT, token=None, username='person'))),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
def test_exit_json_removes_values(self):
|
||||
self.maxDiff = None
|
||||
|
|
|
@ -115,20 +115,20 @@ class TestAnsibleModuleLogSyslog(unittest.TestCase):
|
|||
"""Test the AnsibleModule Log Method"""
|
||||
|
||||
py2_output_data = {
|
||||
u'Text string': b'Text string',
|
||||
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test'.encode('utf-8'),
|
||||
b'Byte string': b'Byte string',
|
||||
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test'.encode('utf-8'),
|
||||
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace').encode('utf-8'),
|
||||
}
|
||||
u'Text string': b'Text string',
|
||||
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test'.encode('utf-8'),
|
||||
b'Byte string': b'Byte string',
|
||||
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test'.encode('utf-8'),
|
||||
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace').encode('utf-8'),
|
||||
}
|
||||
|
||||
py3_output_data = {
|
||||
u'Text string': u'Text string',
|
||||
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
|
||||
b'Byte string': u'Byte string',
|
||||
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
|
||||
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
|
||||
}
|
||||
u'Text string': u'Text string',
|
||||
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
|
||||
b'Byte string': u'Byte string',
|
||||
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
|
||||
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
|
@ -184,12 +184,12 @@ class TestAnsibleModuleLogJournal(unittest.TestCase):
|
|||
"""Test the AnsibleModule Log Method"""
|
||||
|
||||
output_data = {
|
||||
u'Text string': u'Text string',
|
||||
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
|
||||
b'Byte string': u'Byte string',
|
||||
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
|
||||
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
|
||||
}
|
||||
u'Text string': u'Text string',
|
||||
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
|
||||
b'Byte string': u'Byte string',
|
||||
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
|
||||
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
|
||||
}
|
||||
|
||||
# overriding run lets us use context managers for setup/teardown-esque behavior
|
||||
def setUp(self):
|
||||
|
|
|
@ -34,21 +34,21 @@ from ansible.module_utils.basic import return_values, remove_values
|
|||
|
||||
class TestReturnValues(unittest.TestCase):
|
||||
dataset = (
|
||||
('string', frozenset(['string'])),
|
||||
('', frozenset()),
|
||||
(1, frozenset(['1'])),
|
||||
(1.0, frozenset(['1.0'])),
|
||||
(False, frozenset()),
|
||||
(['1', '2', '3'], frozenset(['1', '2', '3'])),
|
||||
(('1', '2', '3'), frozenset(['1', '2', '3'])),
|
||||
({'one': 1, 'two': 'dos'}, frozenset(['1', 'dos'])),
|
||||
({'one': 1, 'two': 'dos',
|
||||
('string', frozenset(['string'])),
|
||||
('', frozenset()),
|
||||
(1, frozenset(['1'])),
|
||||
(1.0, frozenset(['1.0'])),
|
||||
(False, frozenset()),
|
||||
(['1', '2', '3'], frozenset(['1', '2', '3'])),
|
||||
(('1', '2', '3'), frozenset(['1', '2', '3'])),
|
||||
({'one': 1, 'two': 'dos'}, frozenset(['1', 'dos'])),
|
||||
({'one': 1, 'two': 'dos',
|
||||
'three': ['amigos', 'musketeers', None,
|
||||
{'ping': 'pong', 'base': ('balls', 'raquets')}]},
|
||||
frozenset(['1', 'dos', 'amigos', 'musketeers', 'pong', 'balls', 'raquets'])),
|
||||
(u'Toshio くらとみ', frozenset(['Toshio くらとみ'])),
|
||||
('Toshio くらとみ', frozenset(['Toshio くらとみ'])),
|
||||
)
|
||||
(u'Toshio くらとみ', frozenset(['Toshio くらとみ'])),
|
||||
('Toshio くらとみ', frozenset(['Toshio くらとみ'])),
|
||||
)
|
||||
|
||||
def test_return_values(self):
|
||||
for data, expected in self.dataset:
|
||||
|
@ -61,46 +61,46 @@ class TestReturnValues(unittest.TestCase):
|
|||
class TestRemoveValues(unittest.TestCase):
|
||||
OMIT = 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
|
||||
dataset_no_remove = (
|
||||
('string', frozenset(['nope'])),
|
||||
(1234, frozenset(['4321'])),
|
||||
(False, frozenset(['4321'])),
|
||||
(1.0, frozenset(['4321'])),
|
||||
(['string', 'strang', 'strung'], frozenset(['nope'])),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['nope'])),
|
||||
({'one': 1, 'two': 'dos',
|
||||
('string', frozenset(['nope'])),
|
||||
(1234, frozenset(['4321'])),
|
||||
(False, frozenset(['4321'])),
|
||||
(1.0, frozenset(['4321'])),
|
||||
(['string', 'strang', 'strung'], frozenset(['nope'])),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['nope'])),
|
||||
({'one': 1, 'two': 'dos',
|
||||
'three': ['amigos', 'musketeers', None,
|
||||
{'ping': 'pong', 'base': ['balls', 'raquets']}]},
|
||||
frozenset(['nope'])),
|
||||
('Toshio くら', frozenset(['とみ'])),
|
||||
(u'Toshio くら', frozenset(['とみ'])),
|
||||
)
|
||||
('Toshio くら', frozenset(['とみ'])),
|
||||
(u'Toshio くら', frozenset(['とみ'])),
|
||||
)
|
||||
dataset_remove = (
|
||||
('string', frozenset(['string']), OMIT),
|
||||
(1234, frozenset(['1234']), OMIT),
|
||||
(1234, frozenset(['23']), OMIT),
|
||||
(1.0, frozenset(['1.0']), OMIT),
|
||||
(['string', 'strang', 'strung'], frozenset(['strang']), ['string', OMIT, 'strung']),
|
||||
(['string', 'strang', 'strung'], frozenset(['strang', 'string', 'strung']), [OMIT, OMIT, OMIT]),
|
||||
(('string', 'strang', 'strung'), frozenset(['string', 'strung']), [OMIT, 'strang', OMIT]),
|
||||
((1234567890, 345678, 987654321), frozenset(['1234567890']), [OMIT, 345678, 987654321]),
|
||||
((1234567890, 345678, 987654321), frozenset(['345678']), [OMIT, OMIT, 987654321]),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key']),
|
||||
('string', frozenset(['string']), OMIT),
|
||||
(1234, frozenset(['1234']), OMIT),
|
||||
(1234, frozenset(['23']), OMIT),
|
||||
(1.0, frozenset(['1.0']), OMIT),
|
||||
(['string', 'strang', 'strung'], frozenset(['strang']), ['string', OMIT, 'strung']),
|
||||
(['string', 'strang', 'strung'], frozenset(['strang', 'string', 'strung']), [OMIT, OMIT, OMIT]),
|
||||
(('string', 'strang', 'strung'), frozenset(['string', 'strung']), [OMIT, 'strang', OMIT]),
|
||||
((1234567890, 345678, 987654321), frozenset(['1234567890']), [OMIT, 345678, 987654321]),
|
||||
((1234567890, 345678, 987654321), frozenset(['345678']), [OMIT, OMIT, 987654321]),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key']),
|
||||
{'one': 1, 'two': 'dos', 'secret': OMIT}),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
|
||||
{'one': OMIT, 'two': OMIT, 'secret': OMIT}),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
|
||||
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
|
||||
{'one': OMIT, 'two': OMIT, 'secret': OMIT}),
|
||||
({'one': 1, 'two': 'dos', 'three': ['amigos', 'musketeers', None,
|
||||
({'one': 1, 'two': 'dos', 'three': ['amigos', 'musketeers', None,
|
||||
{'ping': 'pong', 'base': ['balls', 'raquets']}]},
|
||||
frozenset(['balls', 'base', 'pong', 'amigos']),
|
||||
{'one': 1, 'two': 'dos', 'three': [OMIT, 'musketeers',
|
||||
None, {'ping': OMIT, 'base': [OMIT, 'raquets']}]}),
|
||||
('This sentence has an enigma wrapped in a mystery inside of a secret. - mr mystery',
|
||||
('This sentence has an enigma wrapped in a mystery inside of a secret. - mr mystery',
|
||||
frozenset(['enigma', 'mystery', 'secret']),
|
||||
'This sentence has an ******** wrapped in a ******** inside of a ********. - mr ********'),
|
||||
('Toshio くらとみ', frozenset(['くらとみ']), 'Toshio ********'),
|
||||
(u'Toshio くらとみ', frozenset(['くらとみ']), u'Toshio ********'),
|
||||
)
|
||||
('Toshio くらとみ', frozenset(['くらとみ']), 'Toshio ********'),
|
||||
(u'Toshio くらとみ', frozenset(['くらとみ']), u'Toshio ********'),
|
||||
)
|
||||
|
||||
def test_no_removal(self):
|
||||
for value, no_log_strings in self.dataset_no_remove:
|
||||
|
|
|
@ -30,27 +30,27 @@ from units.mock.generator import add_method
|
|||
|
||||
# Strings that should be converted into a typed value
|
||||
VALID_STRINGS = (
|
||||
[("'a'", 'a')],
|
||||
[("'1'", '1')],
|
||||
[("1", 1)],
|
||||
[("True", True)],
|
||||
[("False", False)],
|
||||
[("{}", {})],
|
||||
)
|
||||
[("'a'", 'a')],
|
||||
[("'1'", '1')],
|
||||
[("1", 1)],
|
||||
[("True", True)],
|
||||
[("False", False)],
|
||||
[("{}", {})],
|
||||
)
|
||||
|
||||
# Passing things that aren't strings should just return the object
|
||||
NONSTRINGS = (
|
||||
[({'a':1}, {'a':1})],
|
||||
)
|
||||
[({'a':1}, {'a':1})],
|
||||
)
|
||||
|
||||
# These strings are not basic types. For security, these should not be
|
||||
# executed. We return the same string and get an exception for some
|
||||
INVALID_STRINGS = (
|
||||
[("a=1", "a=1", SyntaxError)],
|
||||
[("a.foo()", "a.foo()", None)],
|
||||
[("import foo", "import foo", None)],
|
||||
[("__import__('foo')", "__import__('foo')", ValueError)],
|
||||
)
|
||||
[("a=1", "a=1", SyntaxError)],
|
||||
[("a.foo()", "a.foo()", None)],
|
||||
[("import foo", "import foo", None)],
|
||||
[("__import__('foo')", "__import__('foo')", ValueError)],
|
||||
)
|
||||
|
||||
|
||||
def _check_simple_types(self, code, expected):
|
||||
|
|
|
@ -79,15 +79,15 @@ def _check_mode_unchanged_when_already_0660(self, mode):
|
|||
|
||||
|
||||
SYNONYMS_0660 = (
|
||||
[[0o660]],
|
||||
[['0o660']],
|
||||
[['660']],
|
||||
)
|
||||
[[0o660]],
|
||||
[['0o660']],
|
||||
[['660']],
|
||||
)
|
||||
|
||||
@add_method(_check_no_mode_given_returns_previous_changes,
|
||||
[dict(previous_changes=True)],
|
||||
[dict(previous_changes=False)],
|
||||
)
|
||||
[dict(previous_changes=False)],
|
||||
)
|
||||
@add_method(_check_mode_changed_to_0660,
|
||||
*SYNONYMS_0660
|
||||
)
|
||||
|
@ -131,8 +131,8 @@ def _check_knows_to_change_to_0660_in_check_mode(self, mode):
|
|||
|
||||
@add_method(_check_no_mode_given_returns_previous_changes,
|
||||
[dict(previous_changes=True)],
|
||||
[dict(previous_changes=False)],
|
||||
)
|
||||
[dict(previous_changes=False)],
|
||||
)
|
||||
@add_method(_check_knows_to_change_to_0660_in_check_mode,
|
||||
*SYNONYMS_0660
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue