def test_more_comparison(self): schema = Schema().with_rule(ValueComparisonRule("GE", 123)) results = schema.validate(123) assert 0 == len(results) results = schema.validate(432) assert 0 == len(results) schema = Schema().with_rule(ValueComparisonRule("GT", 123)) results = schema.validate(123) assert 1 == len(results)
def test_not_equal_comparison(self): schema = Schema().with_rule(ValueComparisonRule("NE", 123)) results = schema.validate(123) assert 1 == len(results) results = schema.validate(432) assert 0 == len(results) schema = Schema().with_rule(ValueComparisonRule("NE", "ABC")) results = schema.validate("XYZ") assert 0 == len(results)
def test_or_rule(self): schema = Schema().with_rule( OrRule(ValueComparisonRule("=", 1), ValueComparisonRule("=", 2))) result = schema.validate(-100) assert 2 == len(result) result = schema.validate(1) assert 0 == len(result) result = schema.validate(200) assert 2 == len(result)
def test_and_rule(self): schema = Schema().with_rule( AndRule(ValueComparisonRule(">", 0), ValueComparisonRule("<", 200))) result = schema.validate(-100) assert 1 == len(result) result = schema.validate(100) assert 0 == len(result) result = schema.validate(200) assert 1 == len(result)
def test_match_comparison(self): schema = Schema().with_rule(ValueComparisonRule("LIKE", "A.*")) results = schema.validate("ABC") assert 0 == len(results) results = schema.validate("XYZ") assert 1 == len(results)