mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-04 03:07:01 +00:00
* pythonific!! no camel cases, bitte
* simplified iface attributes parsing
* some improvements, passing tests
* simplified set_interface_option()
* further simplifications
* remove unreachable stmt
* pythonified a file open
* added changelog fragment
* adjustment per PR
* PR: fixed the auto- case
* PR: added testcase and chglog frag for the misleading change report
* extra line removed
* integration is not destructive
(cherry picked from commit 7aae8d5386)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
bc82fe36be
commit
a86f31ac0f
6 changed files with 123 additions and 105 deletions
|
|
@ -24,7 +24,7 @@ class AnsibleFailJson(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class ModuleMocked():
|
||||
class ModuleMocked:
|
||||
def atomic_move(self, src, dst):
|
||||
move(src, dst)
|
||||
|
||||
|
|
@ -148,8 +148,8 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
fail_json_iterations = []
|
||||
for i, options in enumerate(options_list):
|
||||
try:
|
||||
dummy, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'], options['option'],
|
||||
options['value'], options['state'])
|
||||
dummy, lines = interfaces_file.set_interface_option(module, lines, options['iface'], options['option'],
|
||||
options['value'], options['state'])
|
||||
except AnsibleFailJson as e:
|
||||
fail_json_iterations.append("[%d] fail_json message: %s\noptions:\n%s" %
|
||||
(i, str(e), json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))))
|
||||
|
|
@ -181,8 +181,8 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
fail_json_iterations = []
|
||||
options['state'] = state
|
||||
try:
|
||||
dummy, lines = interfaces_file.setInterfaceOption(module, lines,
|
||||
options['iface'], options['option'], options['value'], options['state'])
|
||||
dummy, lines = interfaces_file.set_interface_option(module, lines,
|
||||
options['iface'], options['option'], options['value'], options['state'])
|
||||
except AnsibleFailJson as e:
|
||||
fail_json_iterations.append("fail_json message: %s\noptions:\n%s" %
|
||||
(str(e), json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))))
|
||||
|
|
@ -216,12 +216,12 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
options = options_list[0]
|
||||
fail_json_iterations = []
|
||||
try:
|
||||
changed, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'], options['option'],
|
||||
options['value'], options['state'])
|
||||
changed, lines = interfaces_file.set_interface_option(module, lines, options['iface'], options['option'],
|
||||
options['value'], options['state'])
|
||||
# When a changed is made try running it again for proper idempotency
|
||||
if changed:
|
||||
changed_again, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'],
|
||||
options['option'], options['value'], options['state'])
|
||||
changed_again, lines = interfaces_file.set_interface_option(module, lines, options['iface'],
|
||||
options['option'], options['value'], options['state'])
|
||||
self.assertFalse(changed_again,
|
||||
msg='Second request for change should return false for {0} running on {1}'.format(testname,
|
||||
testfile))
|
||||
|
|
@ -305,8 +305,8 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
options = options_list[0]
|
||||
fail_json_iterations = []
|
||||
try:
|
||||
dummy, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'], options['option'],
|
||||
options['value'], options['state'], options['address_family'])
|
||||
dummy, lines = interfaces_file.set_interface_option(module, lines, options['iface'], options['option'],
|
||||
options['value'], options['state'], options['address_family'])
|
||||
except AnsibleFailJson as e:
|
||||
fail_json_iterations.append("fail_json message: %s\noptions:\n%s" %
|
||||
(str(e), json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue