Skip to content

Commit

Permalink
Merge branch 'ADCM-4569-hotfix' into 'hotfix'
Browse files Browse the repository at this point in the history
ADCM-4569 Changed logic checking invisible_items fields

See merge request arenadata/development/adcm!3068
  • Loading branch information
a-alferov committed Oct 9, 2023
2 parents 409f5e3 + bdbdebf commit fc6a2e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/cm/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions python/cm/tests/test_yaml_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fc6a2e2

Please sign in to comment.