def test_desired_none_values_are_ignored(self): assert utils.do_differ_v1( {"spec": { "a": "b" }}, {"spec": { "c": None }}, ) is False
def test_metadata_detects_change(self): assert utils.do_differ_v1( {"metadata": { "a": 1 }}, {"metadata": { "a": 2 }}, ) is True
def test_detect_missing_keys_in_current(self): assert utils.do_differ_v1( {"spec": { "a": "b" }}, {"spec": { "c": "d" }}, ) is True
def test_detect_different_values(self): assert utils.do_differ_v1( {"spec": { "a": "b" }}, {"spec": { "a": "c" }}, ) is True
def test_ignore_keys_do_not_affect_the_outcome(self): assert utils.do_differ_v1( {"spec": { "a": 1 }}, {"spec": { "a": 2 }}, "a", ) is False
def test_metadata_detects_change_in_presence_of_created_by(self): assert utils.do_differ_v1( {"metadata": { "a": 1, "created_by": 2 }}, {"metadata": { "a": 2 }}, ) is True
def test_metadata_ignores_created_by(self): assert utils.do_differ_v1( {"metadata": { "a": 1, "created_by": 2 }}, {"metadata": { "a": 1 }}, ) is False
def test_extra_keys_in_current_do_not_matter(self): assert utils.do_differ_v1( {"spec": { "a": "b", "c": 3 }}, {"spec": { "a": "b" }}, ) is False
def test_ignore_keys_do_not_mask_other_differences(self): assert utils.do_differ_v1( {"spec": { "a": 1, "b": 1 }}, {"spec": { "a": 2, "b": 2 }}, "a", ) is True
def do_differ(current, desired): if utils.do_differ_v1(current, desired, "client"): return True current_client = current["spec"]["client"] desired_client = desired["spec"]["client"] # Sensu Go API returns 'agent_address' field in the client spec, # but this field is not meant to be set via the providers API. if utils.do_differ(current_client, desired_client, "agent_address", "tls"): return True # Sensu Go API returns some extra fields in the tls spec. # We ignore them, as they are not meant to be set via the # providers API. return utils.do_differ(current_client["tls"], desired_client.get("tls") or {}, "insecure", "tls_server_name", "ca_path")