Example #1
0
 def test_validation_rules_greater_equal_strings(
         self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true with constant
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_greater_equal("hats")\
                       .evaluate.is_valid
     assert answer is True, "Invalid evaluation of greater_equal rule"
     # Evaluates to false with constant
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_greater_equal('z')\
                       .evaluate.is_valid
     assert answer is False, "Invalid evaluation of greater_equal rule"
     # Evaluates to true with attribute
     answer = rule.on(test_object)\
                       .when('a_sg')\
                       .is_greater_equal('a_s')\
                       .evaluate.is_valid
     assert answer is True, "Invalid evaluation of greater_equal rule"
     # Evaluates to false with attribute
     answer = rule.on(test_object)\
                       .when('a_s')\
                       .is_greater_equal('a_sg')\
                       .evaluate.is_valid
     assert answer is False, "Invalid evaluation of greater_equal rule"
Example #2
0
 def test_validation_rules_greater_equal_numbers(
         self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true with constant
     answer = rule.on(test_object)\
                       .when('i')\
                       .is_greater_equal(5)\
                       .evaluate.is_valid
     assert answer is True, "Invalid evaluation of greater_equal rule"
     # Evaluates to false with constant
     answer = rule.on(test_object)\
                       .when('a_g')\
                       .is_greater_equal(50)\
                       .evaluate.is_valid
     assert answer is False, "Invalid evaluation of greater_equal rule"
     # Evaluates to true with attribute
     answer = rule.on(test_object)\
                       .when('a_g')\
                       .is_greater_equal('a_ge')\
                       .evaluate.is_valid
     assert answer is True, "Invalid evaluation of greater_equal rule"
     # Evaluates to false with attribute
     answer = rule.on(test_object)\
                       .when('a_le')\
                       .is_greater_equal('a_ge')\
                       .evaluate.is_valid
     assert answer is False, "Invalid evaluation of greater_equal rule"
Example #3
0
 def test_validation_rules_less_strings(self,
                                        get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true with constant
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_less('z')\
                       .evaluate\
                       .is_valid
     assert answer is True, "Invalid evaluation of less rule"
     # Evaluates to false with constant
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_less('a')\
                       .evaluate\
                       .is_valid
     assert answer is False, "Invalid evaluation of less rule"
     # Evaluates to true with attribute
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_less('z')\
                       .evaluate\
                       .is_valid
     assert answer is True, "Invalid evaluation of less rule"
     # Evaluates to false with attribute
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_less('a_s')\
                       .evaluate\
                       .is_valid
     assert answer is False, "Invalid evaluation of less rule"
Example #4
0
 def test_validation_rules_match(self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true with constant
     answer = rule.on(test_object)\
                       .when('a_s')\
                       .is_match("[a-zA-Z]+")\
                       .evaluate.is_valid
     assert answer is True, "Invalid evaluation of match rule"
     # Evaluates to false with constant
     answer = rule.on(test_object)\
                       .when('a_s')\
                       .is_match("[0-9]+")\
                       .evaluate.is_valid
     assert answer is False, "Invalid evaluation of match rule"
Example #5
0
 def test_validation_rules_not_empty(self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true
     answer = rule.on(test_object)\
                       .when('e')\
                       .is_not_empty\
                       .evaluate\
                       .is_valid
     assert answer is False, "Invalid evaluation of not empty rule"
     # Evaluates to false
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_not_empty\
                       .evaluate\
                       .is_valid
     assert answer is True, "Invalid evaluation of not empty rule"
Example #6
0
 def test_validation_rules_not_none(self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true
     answer = rule.on(test_object)\
                       .when('a_n')\
                       .is_not_none\
                       .evaluate\
                       .is_valid
     assert answer is False, "Invalid evaluation of not none rule"
     # Evaluates to false
     answer = rule.on(test_object)\
                       .when('a_xn')\
                       .is_not_none\
                       .evaluate\
                       .is_valid
     assert answer is True, "Invalid evaluation of not none rule"
Example #7
0
 def test_validation_rules_string(self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true
     answer = rule.on(test_object)\
                       .when('a_s')\
                       .is_string\
                       .evaluate\
                       .is_valid
     assert answer is True, "Invalid evaluation of string rule"
     # Evaluates to false
     answer = rule.on(test_object)\
                       .when('a_l')\
                       .is_string\
                       .evaluate\
                       .is_valid
     assert answer is False, "Invalid evaluation of string rule"
Example #8
0
 def test_validation_rules_integer(self, get_validation_rule_test_object):
     test_object = get_validation_rule_test_object
     rule = Rule()
     # Evaluates to true
     answer = rule.on(test_object)\
                       .when('i')\
                       .is_integer\
                       .evaluate\
                       .is_valid
     assert answer is True, "Invalid evaluation of integer rule"
     # Evaluates to false
     answer = rule.on(test_object)\
                       .when('s')\
                       .is_integer\
                       .evaluate\
                       .is_valid
     assert answer is False, "Invalid evaluation of integer rule"