コード例 #1
0
    def test_5(self):
        import datetime

        expression = Expression("len($xxx) le 9")
        values = {"xxx": u"abcdefghi"}
        result = expression.evaluate(values)
        self.assertEqual(result, True)
コード例 #2
0
 def test_smaller(self):
     import datetime
     expression = Expression("$a > timedelta($b)")
     result = expression.evaluate({
         "a": datetime.timedelta(seconds=100),
         "b": "00:00:120"
     })
     self.assertEqual(result, False)
コード例 #3
0
 def test_sum_smaller(self):
     expression = Expression(
         "(timedelta($a) +  timedelta($b)) < timedelta($c)")
     result = expression.evaluate({
         "a": "04:00:00",
         "b": "05:00:00",
         "c": "08:00:00"
     })
     self.assertEqual(result, False)
コード例 #4
0
    def test_4(self):
        import datetime

        expression = Expression(
            "( ( ( $ap_ausb eq '1' ) and ( $pp_phase in ['1','2'] ) ) or ( ( $ap_ausb eq '3' ) and ( $pp_phase in ['3','4'] ) ) or ( ( $ap_ausb in ['2','4'] ) or ( not bool($ap_ausb) ) ) )"
        )
        values = {
            "ap_austritt": u"1",
            "pp_phase_s": u"",
            "ap_q1": u"Rechtsanwalt und Notarfachangestellte",
            "ap_geschlecht": u"0",
            "ap_austritt_ja": u"ja",
            "programm_info": "",
            "bericht_state_id": 2,
            "pp_austritt_ca": datetime.date(2014, 3, 14),
            "ap_ausb": u"1",
            "pp_phase": u"",
            "pp_ga": [u"2", u""],
            "ap_austritt_date": datetime.date(2014, 3, 14),
            "proj_kommentar": u"",
            "proj_fkz": u"09.00101.13",
            "ap_bj1": u"",
            "ap_bj2": u"",
            "ap_bj3": u"",
            "pp_beginn": u"seit",
            "updated": datetime.datetime(2014, 10, 23, 12, 41, 39),
            "_roles": "",
            "ap_quer": u"1",
            "ap_quali": u"1",
            "pp_gesamtst": u"275",
            "form_info": "",
            "pp_kinder": [u"1", u""],
            "created": datetime.datetime(2014, 9, 23, 14, 5, 30),
            "projekt": None,
            "ausbildungsformat": None,
            "pp_eintritt_ps": datetime.date(2014, 1, 6),
            "logo_einbindung": None,
            "pp_eintritt_vb": None,
            "ap_code": u"A.CB257",
            "ap_q2": u"",
            "ap_austritt_s": u"",
            "ap_mhg": u"0",
            "ap_q3": u"",
        }
        result = expression.evaluate(values)
        self.assertEqual(result, False)
コード例 #5
0
 def test_4(self):
     import datetime
     expression = Expression(
         "( ( ( $ap_ausb eq '1' ) and ( $pp_phase in ['1','2'] ) ) or ( ( $ap_ausb eq '3' ) and ( $pp_phase in ['3','4'] ) ) or ( ( $ap_ausb in ['2','4'] ) or ( not bool($ap_ausb) ) ) )"
     )
     values = {
         'ap_austritt': u'1',
         'pp_phase_s': u'',
         'ap_q1': u'Rechtsanwalt und Notarfachangestellte',
         'ap_geschlecht': u'0',
         'ap_austritt_ja': u'ja',
         'programm_info': '',
         'bericht_state_id': 2,
         'pp_austritt_ca': datetime.date(2014, 3, 14),
         'ap_ausb': u'1',
         'pp_phase': u'',
         'pp_ga': [u'2', u''],
         'ap_austritt_date': datetime.date(2014, 3, 14),
         'proj_kommentar': u'',
         'proj_fkz': u'09.00101.13',
         'ap_bj1': u'',
         'ap_bj2': u'',
         'ap_bj3': u'',
         'pp_beginn': u'seit',
         'updated': datetime.datetime(2014, 10, 23, 12, 41, 39),
         '_roles': '',
         'ap_quer': u'1',
         'ap_quali': u'1',
         'pp_gesamtst': u'275',
         'form_info': '',
         'pp_kinder': [u'1', u''],
         'created': datetime.datetime(2014, 9, 23, 14, 5, 30),
         'projekt': None,
         'ausbildungsformat': None,
         'pp_eintritt_ps': datetime.date(2014, 1, 6),
         'logo_einbindung': None,
         'pp_eintritt_vb': None,
         'ap_code': u'A.CB257',
         'ap_q2': u'',
         'ap_austritt_s': u'',
         'ap_mhg': u'0',
         'ap_q3': u''
     }
     result = expression.evaluate(values)
     self.assertEqual(result, False)
コード例 #6
0
 def test_boolvar(self):
     expression = Expression("bool($float)")
     result = expression.evaluate({"float": 1})
     self.assertEqual(result, True)
コード例 #7
0
 def test_notboolor(self):
     expression = Expression("(not bool(0)) or False")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #8
0
 def test_div(self):
     expression = Expression("49 / 7")
     result = expression.evaluate()
     self.assertEqual(result, 7.0)
コード例 #9
0
 def test_boolempty(self):
     expression = Expression("bool($string)")
     result = expression.evaluate({"string": ""})
     self.assertEqual(result, False)
コード例 #10
0
 def test_false(self):
     expression = Expression("False")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #11
0
 def test_plusplus(self):
     expression = Expression("1 + 1 + 1")
     result = expression.evaluate()
     self.assertEqual(result, 3.0)
コード例 #12
0
 def test_1(self):
     expression = Expression(
         "( 'antragsteller' in       ['institutionen_einsicht', 'user', 'antragsteller']   ) == False"
     )
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #13
0
 def test_6(self):
     expression = Expression("( 'LOP-PM' in ['admins'] ) or ( 'False' == 'True' )")
     result = expression.evaluate({})
     self.assertEqual(result, False)
コード例 #14
0
 def test_equal(self):
     expression = Expression("timedelta($a) == timedelta($b)")
     result = expression.evaluate({"a": "01:30:00", "b": "00:90:00"})
     self.assertEqual(result, True)
コード例 #15
0
 def test_sum_smaller(self):
     expression = Expression("(timedelta($a) +  timedelta($b)) < timedelta($c)")
     result = expression.evaluate({"a": "04:00:00", "b": "05:00:00", "c": "08:00:00"})
     self.assertEqual(result, False)
コード例 #16
0
    def test_smaller(self):
        import datetime

        expression = Expression("$a > timedelta($b)")
        result = expression.evaluate({"a": datetime.timedelta(seconds=100), "b": "00:00:120"})
        self.assertEqual(result, False)
コード例 #17
0
 def test_len4ticks(self):
     expression = Expression("len($a)")
     result = expression.evaluate({"a": "''''"})
     self.assertEqual(result, 4)
コード例 #18
0
 def test_addstr(self):
     expression = Expression("$a + 'abc'")
     result = expression.evaluate({"a": u"xyz"})
     self.assertEqual(result, "xyzabc")
コード例 #19
0
 def test_1(self):
     expression = Expression("( 'antragsteller' in       ['institutionen_einsicht', 'user', 'antragsteller']   ) == False")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #20
0
 def test_variable(self):
     expression = Expression("$string")
     result = expression.evaluate({"string": "string"})
     self.assertEqual(result, "string")
コード例 #21
0
 def test_variable(self):
     expression = Expression("$string")
     result = expression.evaluate({"string": "string"})
     self.assertEqual(result, "string")
コード例 #22
0
 def test_2(self):
     expression = Expression(
         "( 'abfrages' eq 'antrags' ) and ( '1' eq '2') or ( 'admin' in ['institutionen_einsicht','user','antragsteller'] ) or ( 'formularmanager' in ['institutionen_einsicht','user','antragsteller'] )"
     )
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #23
0
 def test_missingvariable(self):
     expression = Expression("$missingstring")
     result = expression.evaluate({"string": "string"})
     self.assertEqual(result, None)
コード例 #24
0
 def test_missingvariable(self):
     expression = Expression("$missingstring")
     result = expression.evaluate({"string": "string"})
     self.assertEqual(result, None)
コード例 #25
0
 def test_nottrue(self):
     expression = Expression("not True")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #26
0
 def test_boolvar(self):
     expression = Expression("bool($float)")
     result = expression.evaluate({"float": 1})
     self.assertEqual(result, True)
コード例 #27
0
 def test_mul(self):
     expression = Expression("7 * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
コード例 #28
0
 def test_plusnediv(self):
     expression = Expression("2 + 2 == 8 / 2")
     result = expression.evaluate()
     self.assertEqual(result, True)
コード例 #29
0
 def test_addmulpar(self):
     expression = Expression("(4 + 3) * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
コード例 #30
0
 def test_stringwithspace(self):
     expression = Expression("'foo and bar'")
     result = expression.evaluate()
     self.assertEqual(result, "foo and bar")
コード例 #31
0
 def test_addmulpar(self):
     expression = Expression("(4 + 3) * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
コード例 #32
0
 def test_true(self):
     expression = Expression("True")
     result = expression.evaluate()
     self.assertEqual(result, True)
コード例 #33
0
 def test_notboolor(self):
     expression = Expression("(not bool(0)) or False")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #34
0
 def test_boolempty(self):
     expression = Expression("bool($string)")
     result = expression.evaluate({"string": ""})
     self.assertEqual(result, False)
コード例 #35
0
 def test_stringwithspace(self):
     expression = Expression("'foo and bar'")
     result = expression.evaluate()
     self.assertEqual(result, "foo and bar")
コード例 #36
0
 def test_len4ticks(self):
     expression = Expression("len($a)")
     result = expression.evaluate({"a": "''''"})
     self.assertEqual(result, 4)
コード例 #37
0
 def test_addstr(self):
     expression = Expression("$a + 'abc'")
     result = expression.evaluate({"a": u"xyz"})
     self.assertEqual(result, 'xyzabc')
コード例 #38
0
 def test_6(self):
     expression = Expression("( 'LOP-PM' in ['admins'] ) or ( 'False' == 'True' )")
     result = expression.evaluate({})
     self.assertEqual(result, False)
コード例 #39
0
 def test_equal(self):
     expression = Expression("timedelta($a) == timedelta($b)")
     result = expression.evaluate({"a": "01:30:00", "b": "00:90:00"})
     self.assertEqual(result, True)
コード例 #40
0
 def test_8(self):
     expression = Expression("bool($x) and ($x == 1)")
     result = expression.evaluate({"x": 0})
     self.assertEqual(result, False)
コード例 #41
0
 def test_2(self):
     expression = Expression("( 'abfrages' eq 'antrags' ) and ( '1' eq '2') or ( 'admin' in ['institutionen_einsicht','user','antragsteller'] ) or ( 'formularmanager' in ['institutionen_einsicht','user','antragsteller'] )")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #42
0
 def test_false(self):
     expression = Expression("False")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #43
0
 def test_5(self):
     import datetime
     expression = Expression("len($xxx) le 9")
     values = {'xxx': u'abcdefghi'}
     result = expression.evaluate(values)
     self.assertEqual(result, True)
コード例 #44
0
 def test_listing(self):
     expression = Expression("[1,2,3]")
     result = expression.evaluate()
     self.assertEqual(result, [1, 2, 3])
コード例 #45
0
 def test_8(self):
     expression = Expression("bool($x) and ($x == 1)")
     result = expression.evaluate({'x': 0})
     self.assertEqual(result, False)
コード例 #46
0
 def test_nottrue(self):
     expression = Expression("not True")
     result = expression.evaluate()
     self.assertEqual(result, False)
コード例 #47
0
 def test_true(self):
     expression = Expression("True")
     result = expression.evaluate()
     self.assertEqual(result, True)
コード例 #48
0
 def test_notfalse(self):
     expression = Expression("not False")
     result = expression.evaluate()
     self.assertEqual(result, True)
コード例 #49
0
 def test_listing(self):
     expression = Expression("[1,2,3]")
     result = expression.evaluate()
     self.assertEqual(result, [1, 2, 3])
コード例 #50
0
 def test_plusplus(self):
     expression = Expression("1 + 1 + 1")
     result = expression.evaluate()
     self.assertEqual(result, 3.0)
コード例 #51
0
 def test_notfalse(self):
     expression = Expression("not False")
     result = expression.evaluate()
     self.assertEqual(result, True)
コード例 #52
0
 def test_sub(self):
     expression = Expression("7 - 4")
     result = expression.evaluate()
     self.assertEqual(result, 3.0)
コード例 #53
0
 def test_sub(self):
     expression = Expression("7 - 4")
     result = expression.evaluate()
     self.assertEqual(result, 3.0)
コード例 #54
0
 def test_mul(self):
     expression = Expression("7 * 7")
     result = expression.evaluate()
     self.assertEqual(result, 49.0)
コード例 #55
0
 def test_number(self):
     expression = Expression("1")
     result = expression.evaluate()
     self.assertEqual(result, 1.0)
コード例 #56
0
 def test_number(self):
     expression = Expression("1")
     result = expression.evaluate()
     self.assertEqual(result, 1.0)
コード例 #57
0
 def test_addmul(self):
     expression = Expression("4 + 3 * 7")
     result = expression.evaluate()
     self.assertEqual(result, 25.0)
コード例 #58
0
 def test_div(self):
     expression = Expression("49 / 7")
     result = expression.evaluate()
     self.assertEqual(result, 7.0)
コード例 #59
0
 def test_plusnediv(self):
     expression = Expression("2 + 2 == 8 / 2")
     result = expression.evaluate()
     self.assertEqual(result, True)
コード例 #60
0
 def test_addmul(self):
     expression = Expression("4 + 3 * 7")
     result = expression.evaluate()
     self.assertEqual(result, 25.0)