def test_valueConstraintType_picklist_parse(): """If valueConstraintType picklist, valueConstraint parsed on whitespace.""" st = TAPStatementTemplate() st.propertyID = "dcterms:creator" st.valueConstraintType = "picklist" st.valueConstraint = "one two three" st._valueConstraintType_picklist_parse(config_dict) assert st.valueConstraint == ["one", "two", "three"]
def test_valueConstraintType_picklist_parse_case_insensitive(): """Value constraint types are case-insensitive.""" st = TAPStatementTemplate() st.propertyID = "dcterms:creator" st.valueConstraintType = "PICKLIST" st.valueConstraint = "one two three" # extra whitespace st._valueConstraintType_picklist_parse(config_dict) assert st.valueConstraint == ["one", "two", "three"]
def test_warn_if_valueConstraintType_pattern_used_with_any_value_shape(): """Regular expressions cannot conform to value shapes.""" sc = TAPStatementTemplate() sc.propertyID = ":status" sc.valueConstraintType = "pattern" sc.valueShape = "Person" sc._valueConstraintType_pattern_warn_if_used_with_value_shape() assert len(sc.state_warns) == 1
def test_valueConstraintType_languagetag_parse(): """If valueConstraintType list, valueConstraint parsed on whitespace.""" sc = TAPStatementTemplate() sc.propertyID = "dcterms:creator" sc.valueConstraintType = "languagetag" sc.valueConstraint = "fr it de" sc._valueConstraintType_languageTag_parse(config_dict) assert sc.valueConstraint == ["fr", "it", "de"]
def test_valueConstraintType_pattern_warn_if_not_valid_regex(): """For valueConstraintType pattern, warns if valueConstraint not valid regex.""" sc = TAPStatementTemplate() sc.propertyID = ":status" sc.valueConstraintType = "pattern" sc.valueConstraint = "approved_(*" sc._valueConstraintType_pattern_warn_if_valueConstraint_not_valid_regex() assert len(sc.state_warns) == 1
def test_valueConstraintType_pattern_is_valid_regex(): """For valueConstraintType pattern, valueConstraint must be valid regex.""" sc = TAPStatementTemplate() sc.propertyID = ":status" sc.valueConstraintType = "pattern" sc.valueConstraint = "approved_*" sc._valueConstraintType_pattern_warn_if_valueConstraint_not_valid_regex() assert sc.valueConstraint sc.valueConstraint = "/approved_*/" sc._valueConstraintType_pattern_warn_if_valueConstraint_not_valid_regex() assert sc.valueConstraint == "/approved_*/" sc.valueConstraint = "^2020 August" sc._valueConstraintType_pattern_warn_if_valueConstraint_not_valid_regex() assert sc.valueConstraint sc.valueConstraint = "'confidential'" sc._valueConstraintType_pattern_warn_if_valueConstraint_not_valid_regex() assert sc.valueConstraint == "'confidential'"
def test_valueConstraintType_warn_if_used_without_valueConstraint(): sc = TAPStatementTemplate() sc.propertyID = ":status" sc.valueConstraintType = "pattern" sc._valueConstraintType_warn_if_used_without_valueConstraint() assert len(sc.state_warns) == 1