mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-28 18:34:42 +00:00
attribute should match for all
This commit is contained in:
@@ -44,7 +44,7 @@ def match_json_property(module, data, expr, value=None):
|
|||||||
def _match_value(buf, v):
|
def _match_value(buf, v):
|
||||||
if isinstance(buf, list):
|
if isinstance(buf, list):
|
||||||
# convert all values from bool to str and lowercase them
|
# convert all values from bool to str and lowercase them
|
||||||
return v.lower() in [str(i).lower() for i in buf]
|
return all([str(i).lower() == v.lower() for i in buf])
|
||||||
elif isinstance(buf, str):
|
elif isinstance(buf, str):
|
||||||
return v.lower() == content.lower()
|
return v.lower() == content.lower()
|
||||||
elif isinstance(buf, bool):
|
elif isinstance(buf, bool):
|
||||||
|
|||||||
@@ -60,6 +60,24 @@ def test_boolean_value():
|
|||||||
assert match_json_property(None, data, "containers[*].connected", "TRUE")
|
assert match_json_property(None, data, "containers[*].connected", "TRUE")
|
||||||
assert match_json_property(None, data, "containers[0].poweron", "false")
|
assert match_json_property(None, data, "containers[0].poweron", "false")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"containers": [
|
||||||
|
{"image": "nginx", "ready": False},
|
||||||
|
{"image": "python", "ready": False},
|
||||||
|
{"image": "mongo", "ready": True}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
assert not match_json_property(None, data, "containers[*].ready", "true")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"containers": [
|
||||||
|
{"image": "nginx", "ready": True},
|
||||||
|
{"image": "python", "ready": True},
|
||||||
|
{"image": "mongo", "ready": True}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
assert match_json_property(None, data, "containers[*].ready", "true")
|
||||||
|
|
||||||
|
|
||||||
def test_valid_expression():
|
def test_valid_expression():
|
||||||
data = dict(key="ansible", value="unit-test")
|
data = dict(key="ansible", value="unit-test")
|
||||||
|
|||||||
Reference in New Issue
Block a user