diff --git a/python/cm/checker.py b/python/cm/checker.py index efabfb0901..bfa5e2bda1 100644 --- a/python/cm/checker.py +++ b/python/cm/checker.py @@ -119,8 +119,8 @@ def match_list(data, rules, rule, path, parent=None): def match_dict(data, rules, rule, path, parent=None): check_match_type("match_dict", data, dict, path, rule, parent) - if "required_items" in rules[rule] or "invisible_items" in rules[rule]: - for i in rules[rule].get("required_items", []) + rules[rule].get("invisible_items", []): + if "required_items" in rules[rule]: + for i in rules[rule].get("required_items", []): if i not in data: raise FormatError(path, f'There is no required key "{i}" in map.', data, rule) diff --git a/python/cm/inventory.py b/python/cm/inventory.py index 77e88278ef..56ff99f533 100644 --- a/python/cm/inventory.py +++ b/python/cm/inventory.py @@ -193,7 +193,7 @@ def get_before_upgrade(obj: ADCMEntity, host: Host | None) -> dict: name=obj_prototype.name, parent__name=obj_prototype.parent.name, bundle_id=bundle_id ) else: - old_proto = Prototype.objects.get(name=obj_prototype.name, bundle_id=bundle_id) + old_proto = Prototype.objects.get(name=obj_prototype.name, bundle_id=bundle_id, parent=None) except Prototype.DoesNotExist: logger.info("Can't get old proto for %s. Old bundle id: %s", obj, bundle_id) diff --git a/python/cm/tests/test_yaml_checker.py b/python/cm/tests/test_yaml_checker.py index e871797ce8..3fd3fe3b49 100644 --- a/python/cm/tests/test_yaml_checker.py +++ b/python/cm/tests/test_yaml_checker.py @@ -69,11 +69,10 @@ class TestYAMLChecker(TestCase): def test_initial_data_correct_success(self): process_rule(data=test_data, rules=test_rules, name="root") - def test_invisible_field_not_in_data_fail(self): + def test_invisible_field_not_in_data_success(self): rules = deepcopy(test_rules) rules["replica_item"]["invisible_items"].append("non_existent_field") - with self.assertRaises(FormatError): - process_rule(data=test_data, rules=rules, name="root") + process_rule(data=test_data, rules=rules, name="root") def test_invisible_items_in_match_none_fail(self): rules = deepcopy(test_rules)