def test_node_attr(node, attr, invalid_values): """Tests node attribute validation. """ valid_value = getattr(node, attr) for value in invalid_values: setattr(node, attr, value) assert pyessv.is_valid(node) == False, (attr, value) assert len(pyessv.get_errors(node)) >= 1, (pyessv.get_errors(node), attr, value) setattr(node, attr, valid_value) assert pyessv.is_valid(node) == True, (pyessv.get_errors(node), attr, valid_value) assert len(pyessv.get_errors(node)) == 0
def _test_node_attr(instance, attr, invalid_values): """Tests node attribute validation. """ valid_value = getattr(instance, attr) for value in invalid_values: setattr(instance, attr, value) assert LIB.is_valid(instance) == False, (attr, value) assert len(LIB.get_errors(instance)) >= 1, (LIB.get_errors(instance), attr, value) setattr(instance, attr, valid_value) assert LIB.is_valid(instance) == True, (LIB.get_errors(instance), attr, valid_value) assert len(LIB.get_errors(instance)) == 0
def test_regex_collection_negative(): """pyessv-tests: validate --> reg-ex collection --> negative """ collection = tu.create_collection_01() collection.term_regex = r'^[a-z\-]*$' term = tu.create_term_01(collection=collection) term.canonical_name = 'ABC-DEF' assert pyessv.is_valid(term) == False
def test_regex_collection(): """pyessv-tests: validate --> reg-ex collection """ collection = tu.create_collection_01() collection.term_regex = r'^[a-z\-]*$' term = tu.create_term_01(collection=collection) term.canonical_name = 'abc-def' assert pyessv.is_valid(term) == True