Example #1
0
 def test_rule_txt_with_three_rules(self):
     txt_rule = "L1>=20\n" \
                "L2=3\n" \
                "W<=90".splitlines()
     exp_result = [("L1", ">=", 20),
                   ("L2", "=", 3),
                   ("W", "<=", 90)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
Example #2
0
    def test_W_03(self):
        txt_rule = "L1>0\n" \
                   "L1<10\n" \
                   "L2>0\n" \
                   "L2<10\n" \
                   "W==90".splitlines()
        rules = Rule.parse(txt_rule)

        Equation.validate_rules_for_w(rules)
Example #3
0
    def test_W_03(self):
        txt_rule = "L1>0\n" \
                   "L1<10\n" \
                   "L2>0\n" \
                   "L2<10\n" \
                   "W==90".splitlines()
        rules = Rule.parse(txt_rule)

        Equation.validate_rules_for_w(rules)
Example #4
0
    def test_W_01(self):
        txt_rule = "L1>0\n" \
                   "L1<10\n" \
                   "L2>0\n" \
                   "L2<10\n" \
                   "W<=90".splitlines()
        rules = Rule.parse(txt_rule)

        exceptions = (RuleException)
        with self.assertRaises(exceptions):
            Equation.validate_rules_for_w(rules)
Example #5
0
    def test_W_01(self):
        txt_rule = "L1>0\n" \
                   "L1<10\n" \
                   "L2>0\n" \
                   "L2<10\n" \
                   "W<=90".splitlines()
        rules = Rule.parse(txt_rule)

        exceptions = (RuleException)
        with self.assertRaises(exceptions):
            Equation.validate_rules_for_w(rules)
Example #6
0
 def test_rule_txt_as_none(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         Rule.parse(None)
Example #7
0
 def test_rule_txt_with_missing_value(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1>=".splitlines()
         Rule.parse(txt_rule)
Example #8
0
 def test_rule_txt_with_invalid_value_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1>=10.6".splitlines()
         Rule.parse(txt_rule)
Example #9
0
 def test_rule_txt_with_invalid_operand_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1<>20".splitlines()
         Rule.parse(txt_rule)
Example #10
0
 def test_rule_txt_with_missing_element(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = " >=20".splitlines()
         Rule.parse(txt_rule)
Example #11
0
 def test_rule_txt_with_invalid_element_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "12>=20".splitlines()
         Rule.parse(txt_rule)
Example #12
0
 def test_rule_txt_with_invalid_value_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1>=10.6".splitlines()
         Rule.parse(txt_rule)
Example #13
0
 def test_rule_txt_with_missing_element(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = " >=20".splitlines()
         Rule.parse(txt_rule)
Example #14
0
 def test_rule_txt_with_one_rule_and_spaces(self):
     txt_rule = "L1 >= 20".splitlines()
     exp_result = [("L1", ">=", 20)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
Example #15
0
 def test_rule_txt_with_one_rule_and_spaces(self):
     txt_rule = "L1 >= 20".splitlines()
     exp_result = [("L1", ">=", 20)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
Example #16
0
 def test_rule_txt_with_three_rules(self):
     txt_rule = "L1>=20\n" \
                "L2=3\n" \
                "W<=90".splitlines()
     exp_result = [("L1", ">=", 20), ("L2", "=", 3), ("W", "<=", 90)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
Example #17
0
 def test_rule_txt_with_two_rules(self):
     txt_rule = "L1>=20\n" \
                "L2=3".splitlines()
     exp_result = [("L1", ">=", 20), ("L2", "=", 3)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
Example #18
0
 def test_rule_txt_with_missing_value(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1>=".splitlines()
         Rule.parse(txt_rule)
Example #19
0
 def test_rule_txt_as_none(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         Rule.parse(None)
Example #20
0
 def test_rule_txt_with_two_rules(self):
     txt_rule = "L1>=20\n" \
                "L2=3".splitlines()
     exp_result = [("L1", ">=", 20),
                   ("L2", "=", 3)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
Example #21
0
 def test_rule_txt_with_invalid_element_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "12>=20".splitlines()
         Rule.parse(txt_rule)
Example #22
0
 def test_rule_txt_with_invalid_operand_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1<>20".splitlines()
         Rule.parse(txt_rule)
Example #23
0
 def test_rule_txt_as_empty_string(self):
     exceptions = (RuleException)
     self.assertEqual([], Rule.parse(""))
Example #24
0
 def test_rule_txt_as_empty_string(self):
     exceptions = (RuleException)
     self.assertEqual([], Rule.parse(""))