mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Merge pull request #55595 from cvedel/wrong-isinstance-in-ini-options_absent
Wrong isinstance in ini options absent
This commit is contained in:
commit
6ba77aa282
2 changed files with 13 additions and 2 deletions
|
@ -211,7 +211,7 @@ def options_absent(name, sections=None, separator="="):
|
|||
return ret
|
||||
except AttributeError:
|
||||
cur_section = section
|
||||
if isinstance(sections[section], (dict, OrderedDict)):
|
||||
if isinstance(sections[section], list):
|
||||
for key in sections[section]:
|
||||
cur_value = cur_section.get(key)
|
||||
if not cur_value:
|
||||
|
@ -248,7 +248,7 @@ def options_absent(name, sections=None, separator="="):
|
|||
if section not in ret["changes"]:
|
||||
ret["changes"].update({section: {}})
|
||||
ret["changes"][section].update({key: current_value})
|
||||
if not isinstance(sections[section], (dict, OrderedDict)):
|
||||
if not isinstance(sections[section], list):
|
||||
ret["changes"].update({section: current_value})
|
||||
# break
|
||||
ret["comment"] = "Changes take effect"
|
||||
|
|
|
@ -111,6 +111,17 @@ class IniManageTestCase(TestCase, LoaderModuleMockMixin):
|
|||
comt = "No anomaly detected"
|
||||
ret.update({"comment": comt, "result": True})
|
||||
self.assertDictEqual(ini_manage.options_absent(name), ret)
|
||||
original = {"Tables": {"key1": "1", "key2": "2", "key3": "3", "key4": "4"}}
|
||||
sections = {"Tables": ["key2", "key3"]}
|
||||
changes = {"Tables": {"key2": "2", "key3": "3"}}
|
||||
with patch.dict(
|
||||
ini_manage.__salt__,
|
||||
{"ini.remove_option": MagicMock(side_effect=["2", "3"])},
|
||||
):
|
||||
with patch.dict(ini_manage.__opts__, {"test": False}):
|
||||
comt = "Changes take effect"
|
||||
ret.update({"comment": comt, "result": True, "changes": changes})
|
||||
self.assertDictEqual(ini_manage.options_absent(name, sections), ret)
|
||||
|
||||
# 'sections_present' function tests: 1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue