Skip to content

Commit

Permalink
Merge pull request #157 from JordanCHW/fix-conditional-requirement
Browse files Browse the repository at this point in the history
Fix the conditional requirements on list property
  • Loading branch information
mraineri authored Jun 17, 2022
2 parents 50db515 + 8d7a25a commit 98e8034
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions common/interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,27 @@ def validatePropertyRequirement(propResourceObj, profile_entry, rf_payload_tuple
else:
my_logger.debug('propRequirement with value: ' + str(rf_payload_item if not isinstance(
rf_payload_item, dict) else 'dict'))

# Check the conditional requirements first or the requirements won't apply correctly against
# a list.
if "ConditionalRequirements" in profile_entry:
innerList = profile_entry["ConditionalRequirements"]
for item in innerList:
try:
if checkConditionalRequirement(propResourceObj, item, rf_payload_tuple):
my_logger.info("\tCondition DOES apply")
conditionalMsgs, conditionalCounts = validatePropertyRequirement(
propResourceObj, item, rf_payload_tuple, itemname, chkCondition = True)
counts.update(conditionalCounts)
for item in conditionalMsgs:
item.name = item.name.replace('.', '.Conditional.', 1)
msgs.extend(conditionalMsgs)
else:
my_logger.info("\tCondition does not apply")
except ValueError as e:
my_logger.info("\tCondition was skipped due to payload error")
counts['errorProfileComparisonError'] += 1

# If we're working with a list, then consider MinCount, Comparisons, then execute on each item
# list based comparisons include AnyOf and AllOf
if isinstance(rf_payload_item, list):
Expand Down Expand Up @@ -384,24 +405,6 @@ def validatePropertyRequirement(propResourceObj, profile_entry, rf_payload_tuple
msg.name = itemname + '.' + msg.name
if not success:
my_logger.error("WriteRequirement failed")
if "ConditionalRequirements" in profile_entry:
innerList = profile_entry["ConditionalRequirements"]
for item in innerList:
try:
if checkConditionalRequirement(propResourceObj, item, rf_payload_tuple):
my_logger.info("\tCondition DOES apply")
conditionalMsgs, conditionalCounts = validatePropertyRequirement(
propResourceObj, item, rf_payload_tuple, itemname, chkCondition = True)
counts.update(conditionalCounts)
for item in conditionalMsgs:
item.name = item.name.replace('.', '.Conditional.', 1)
msgs.extend(conditionalMsgs)
else:
my_logger.info("\tCondition does not apply")
except ValueError as e:
my_logger.info("\tCondition was skipped due to payload error")
counts['errorProfileComparisonError'] += 1

if "MinSupportValues" in profile_entry:
msg, success = validateSupportedValues(
profile_entry["MinSupportValues"],
Expand Down

0 comments on commit 98e8034

Please sign in to comment.