Skip to content

Commit

Permalink
Fix constraint violation error message
Browse files Browse the repository at this point in the history
(cherry picked from commit c5d43f7)
  • Loading branch information
jonathan-r-thorpe committed Nov 15, 2023
1 parent 8409b8e commit c8caa23
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nmostesting/suites/IS1201Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,21 +1456,22 @@ def check_constraint(self, test, constraint, type_name, is_sequence, test_metada
context + ": defaultValue ")

datatype = self.resolve_datatype(test, type_name)
constraint_type = "NcPropertyConstraintsNumber" \
if constraint.get("propertyId") else "NcParameterConstraintsNumber"

# check NcXXXConstraintsNumber
if constraint.get("minimum") or constraint.get("maximum") or constraint.get("step"):
constraint_type = "NcPropertyConstraintsNumber" \
if constraint.get("propertyId") else "NcParameterConstraintsNumber"
if datatype not in ["NcInt16", "NcInt32", "NcInt64", "NcUint16", "NcUint32",
"NcUint64", "NcFloat32", "NcFloat64"]:
test_metadata["error"] = True
test_metadata["error_msg"] = context + " of type " + datatype + \
test_metadata["error_msg"] = context + ". " + datatype + \
" can not be constrainted by " + constraint_type + "."
# check NcXXXConstraintsString
if constraint.get("maxCharacters") or constraint.get("pattern"):
constraint_type = "NcPropertyConstraintsString" \
if constraint.get("propertyId") else "NcParameterConstraintsString"
if datatype not in ["NcString"]:
test_metadata["error"] = True
test_metadata["error_msg"] = context + "of type " + datatype + \
test_metadata["error_msg"] = context + ". " + datatype + \
" can not be constrainted by " + constraint_type + "."

def do_validate_runtime_constraints_test(self, test, nc_object, class_manager, context=""):
Expand Down

0 comments on commit c8caa23

Please sign in to comment.