def test_delkey_nested_key(): with patch.dict( grainsmod.__grains__, {"a": "aval", "b": {"nested": "val"}, "c": 8} ): res = grainsmod.delkey("b:nested") assert res["result"] assert res["changes"] == {"b": {}} assert grainsmod.__grains__ == {"a": "aval", "b": {}, "c": 8}
def test_delkey_nested_key(self): with patch.dict( grainsmod.__grains__, {"a": "aval", "b": {"nested": "val"}, "c": 8} ): res = grainsmod.delkey("b:nested") self.assertTrue(res["result"]) self.assertEqual(res["changes"], {"b": {}}) self.assertEqual(grainsmod.__grains__, {"a": "aval", "b": {}, "c": 8})
def test_delkey_nested_key_force_needed(): with patch.dict( grainsmod.__grains__, {"a": "aval", "b": {"nested": "val"}, "c": 8} ): res = grainsmod.delkey("b", force=True) assert res["comment"].find("Use 'force=True' to overwrite.") == -1 assert res["result"] assert res["changes"] == {"b": None} assert grainsmod.__grains__ == {"a": "aval", "c": 8}