示例#1
0
 def test_parse_expr_missing_brackets(self):
     expr = parse_expr(tokenise('true=false or true=true))'))[0]
     self.assertTrue(expr(None))
     expr = parse_expr(tokenise('true=false or true=false))'))[0]
     self.assertFalse(expr(None))
     expr = parse_expr(tokenise('true=true or true=false))'))[0]
     self.assertTrue(expr(None))
示例#2
0
    def test_parse_expr_accessing_missing_params(self):
        tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
        expr = parse_expr(tokenise('flagged'))[0]
        self.assertFalse(expr(Folder(name="aabbccdd")))

        expr = parse_expr(tokenise('due=today'), now=tue)[0]
        self.assertFalse(expr(Folder(name="aabbccdd")))
示例#3
0
 def test_parse_expr_accessing_missing_params (self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise ('flagged'))[0]
     self.assertFalse(expr (Folder(name="aabbccdd")))
     
     expr = parse_expr(tokenise ('due=today'),now=tue)[0]
     self.assertFalse(expr (Folder(name="aabbccdd")))
示例#4
0
 def test_parse_expr_missing_brackets (self):
     expr = parse_expr(tokenise ('true=false or true=true))'))[0]
     self.assertTrue(expr (None))
     expr = parse_expr(tokenise ('true=false or true=false))'))[0]
     self.assertFalse(expr (None))
     expr = parse_expr(tokenise ('true=true or true=false))'))[0]
     self.assertTrue(expr (None))
示例#5
0
    def test_bug_2013_04_27(self):
        expr = parse_expr(tokenise('(type=Folder) and !name=".*Folder 2"'))[0]
        self.assertTrue(expr(Folder(name="Miscellaneous")))
        self.assertFalse(expr(Folder(name="xxx Folder 2")))

        expr = parse_expr(tokenise('(type=Folder) and name!=".*Folder 2"'))[0]
        self.assertTrue(expr(Folder(name="Miscellaneous")))
        self.assertFalse(expr(Folder(name="xxx Folder 2")))
示例#6
0
 def test_bug_2013_04_27 (self):
     expr = parse_expr(tokenise ('(type=Folder) and !name=".*Folder 2"'))[0]
     self.assertTrue(expr (Folder(name="Miscellaneous")))
     self.assertFalse(expr (Folder(name="xxx Folder 2")))
     
     expr = parse_expr(tokenise ('(type=Folder) and name!=".*Folder 2"'))[0]
     self.assertTrue(expr (Folder(name="Miscellaneous")))
     self.assertFalse(expr (Folder(name="xxx Folder 2")))
示例#7
0
 def test_parse_expr_not (self):
     expr = parse_expr(tokenise ('!true'))[0]
     self.assertFalse(expr (None))
     
     expr = parse_expr(tokenise ('!(true)'))[0]
     self.assertFalse(expr (None))
     
     expr = parse_expr(tokenise ('(!(true))'))[0]
     self.assertFalse(expr (None))
示例#8
0
 def test_bug_2013_04_28 (self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise ("flagged or true"), now=tue)[0]
     self.assertTrue(expr (Project()))
     
     expr = parse_expr(tokenise ("flagged or due=today"), now=tue)[0]
     self.assertFalse(expr (Project()))
     self.assertTrue(expr (Project(flagged=True)))
     self.assertTrue(expr (Project(date_due=tue)))
示例#9
0
    def test_bug_2013_04_28(self):
        tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
        expr = parse_expr(tokenise("flagged or true"), now=tue)[0]
        self.assertTrue(expr(Project()))

        expr = parse_expr(tokenise("flagged or due=today"), now=tue)[0]
        self.assertFalse(expr(Project()))
        self.assertTrue(expr(Project(flagged=True)))
        self.assertTrue(expr(Project(date_due=tue)))
示例#10
0
    def test_parse_expr_not(self):
        expr = parse_expr(tokenise('!true'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('!(true)'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('(!(true))'))[0]
        self.assertFalse(expr(None))
示例#11
0
 def test_bug_2013_04_24 (self):
     expr = parse_expr(tokenise ('(type="Folder") and (name!="^Misc")'))[0]
     self.assertFalse(expr (Folder(name="Miscellaneous")))
     expr = parse_expr(tokenise ('(type="Project") and (name="Misc")'))[0]
     self.assertTrue(expr (Project(name="Miscellaneous")))
     self.assertFalse(expr (Project(name="xxx")))
     expr = parse_expr(tokenise ('((type="Project") and (name="Misc"))'))[0]
     self.assertTrue(expr (Project(name="Miscellaneous")))
     self.assertFalse(expr (Project(name="xxx")))
     self.assertFalse(expr (Folder(name="Misc")))
示例#12
0
 def test_bug_2013_04_24(self):
     expr = parse_expr(tokenise('(type="Folder") and (name!="^Misc")'))[0]
     self.assertFalse(expr(Folder(name="Miscellaneous")))
     expr = parse_expr(tokenise('(type="Project") and (name="Misc")'))[0]
     self.assertTrue(expr(Project(name="Miscellaneous")))
     self.assertFalse(expr(Project(name="xxx")))
     expr = parse_expr(tokenise('((type="Project") and (name="Misc"))'))[0]
     self.assertTrue(expr(Project(name="Miscellaneous")))
     self.assertFalse(expr(Project(name="xxx")))
     self.assertFalse(expr(Folder(name="Misc")))
示例#13
0
 def test_bug_2013_04_26 (self):
     expr = parse_expr(tokenise ('text=^Work$|^Miscellaneous$'))[0]
     self.assertFalse(expr (Folder(name="Misc")))
     self.assertTrue(expr (Folder(name="Miscellaneous")))
     
     expr = parse_expr(tokenise ('(type=Folder)'))[0]
     self.assertTrue(expr (Folder(name="Miscellaneous")))
     
     expr = parse_expr(tokenise ('(type=Folder)and(text=^Work$|^Miscellaneous$)'))[0]
     self.assertFalse(expr (Folder(name="Misc")))
     self.assertTrue(expr (Folder(name="Miscellaneous")))
示例#14
0
    def test_parse_expr_not_equals(self):
        expr = parse_expr(tokenise('true != true'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('true != false'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('false != true'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('false != false'))[0]
        self.assertFalse(expr(None))
示例#15
0
    def test_bug_2013_04_26(self):
        expr = parse_expr(tokenise('text=^Work$|^Miscellaneous$'))[0]
        self.assertFalse(expr(Folder(name="Misc")))
        self.assertTrue(expr(Folder(name="Miscellaneous")))

        expr = parse_expr(tokenise('(type=Folder)'))[0]
        self.assertTrue(expr(Folder(name="Miscellaneous")))

        expr = parse_expr(
            tokenise('(type=Folder)and(text=^Work$|^Miscellaneous$)'))[0]
        self.assertFalse(expr(Folder(name="Misc")))
        self.assertTrue(expr(Folder(name="Miscellaneous")))
示例#16
0
    def test_parse_expr_not_equals (self):
        expr = parse_expr(tokenise ('true != true'))[0]
        self.assertFalse(expr (None))

        expr = parse_expr(tokenise ('true != false'))[0]
        self.assertTrue(expr (None))

        expr = parse_expr(tokenise ('false != true'))[0]
        self.assertTrue(expr (None))
        
        expr = parse_expr(tokenise ('false != false'))[0]
        self.assertFalse(expr (None))
示例#17
0
 def test_parse_expr_date(self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     wed = datetime.strptime('Apr 10 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise ('today'), type_required=STRING_TYPE, now=tue)[0]
     self.assertEquals ("today", expr(None))
     expr = parse_expr(tokenise ('today'), type_required = DATE_TYPE, now=tue)[0]
     self.assertEquals ("2013-04-09", date_range_to_str (expr(None)))
     expr = parse_expr(tokenise ('"last tues"'), type_required = DATE_TYPE, now=tue)[0]
     self.assertEquals ("2013-04-02", date_range_to_str (expr(None)))
     expr = parse_expr(tokenise ('due = today'), now=tue)[0]
     self.assertTrue (expr(Task(name="", date_due=tue)))
     expr = parse_expr(tokenise ('due = start'), now=tue)[0]
     self.assertTrue (expr(Task(name="", date_due=tue, date_to_start=tue)))
     self.assertFalse (expr(Task(name="", date_due=tue, date_to_start=wed)))
     self.assertFalse (expr(Task(name="", date_due=tue)))
示例#18
0
 def test_parse_expr_flagged (self):
     expr = parse_expr(tokenise ('flagged'))[0]
     self.assertTrue(expr (Task(flagged=True)))
     self.assertFalse(expr (Task(flagged=False)))
     
     expr = parse_expr(tokenise ('flagged = true'))[0]
     self.assertTrue(expr (Task(flagged=True)))
     self.assertFalse(expr (Task(flagged=False)))
     
     expr = parse_expr(tokenise ('true = flagged'))[0]
     self.assertTrue(expr (Task(flagged=True)))
     self.assertFalse(expr (Task(flagged=False)))
     
     expr = parse_expr(tokenise ('!flagged'))[0]
     self.assertFalse(expr (Task(flagged=True)))
     self.assertTrue(expr (Task(flagged=False)))
示例#19
0
 def test_bug_2013_04_28_2(self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise("flagged or (due='to tomorrow')"),
                       now=tue)[0]
     self.assertFalse(expr(Task()))
     self.assertTrue(expr(Task(flagged=True)))
     self.assertTrue(expr(Task(date_due=tue)))
示例#20
0
    def test_parse_expr_flagged(self):
        expr = parse_expr(tokenise('flagged'))[0]
        self.assertTrue(expr(Task(flagged=True)))
        self.assertFalse(expr(Task(flagged=False)))

        expr = parse_expr(tokenise('flagged = true'))[0]
        self.assertTrue(expr(Task(flagged=True)))
        self.assertFalse(expr(Task(flagged=False)))

        expr = parse_expr(tokenise('true = flagged'))[0]
        self.assertTrue(expr(Task(flagged=True)))
        self.assertFalse(expr(Task(flagged=False)))

        expr = parse_expr(tokenise('!flagged'))[0]
        self.assertFalse(expr(Task(flagged=True)))
        self.assertTrue(expr(Task(flagged=False)))
示例#21
0
 def test_parse_expr_date(self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     wed = datetime.strptime('Apr 10 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise('today'),
                       type_required=STRING_TYPE,
                       now=tue)[0]
     self.assertEquals("today", expr(None))
     expr = parse_expr(tokenise('today'), type_required=DATE_TYPE,
                       now=tue)[0]
     self.assertEquals("2013-04-09", date_range_to_str(expr(None)))
     expr = parse_expr(tokenise('"last tues"'),
                       type_required=DATE_TYPE,
                       now=tue)[0]
     self.assertEquals("2013-04-02", date_range_to_str(expr(None)))
     expr = parse_expr(tokenise('due = today'), now=tue)[0]
     self.assertTrue(expr(Task(name="", date_due=tue)))
     expr = parse_expr(tokenise('due = start'), now=tue)[0]
     self.assertTrue(expr(Task(name="", date_due=tue, date_to_start=tue)))
     self.assertFalse(expr(Task(name="", date_due=tue, date_to_start=wed)))
     self.assertFalse(expr(Task(name="", date_due=tue)))
示例#22
0
 def test_parse_expr_brackets (self):
     expr = parse_expr(tokenise ('(true)'))[0]
     self.assertTrue(expr (None))
     expr  = parse_expr(tokenise ('(false)'))[0]
     self.assertFalse(expr (None))
     expr  = parse_expr(tokenise (' ( false ) '))[0]
     self.assertFalse(expr (None))
     expr = parse_expr(tokenise ('(false or true)'))[0]
     self.assertTrue(expr (None))
     expr = parse_expr(tokenise ('(false) or (true)'))[0]
     self.assertTrue(expr (None))
     expr = parse_expr(tokenise ('((false) or (true))'))[0]
     self.assertTrue(expr (None))
示例#23
0
 def test_parse_expr_brackets(self):
     expr = parse_expr(tokenise('(true)'))[0]
     self.assertTrue(expr(None))
     expr = parse_expr(tokenise('(false)'))[0]
     self.assertFalse(expr(None))
     expr = parse_expr(tokenise(' ( false ) '))[0]
     self.assertFalse(expr(None))
     expr = parse_expr(tokenise('(false or true)'))[0]
     self.assertTrue(expr(None))
     expr = parse_expr(tokenise('(false) or (true)'))[0]
     self.assertTrue(expr(None))
     expr = parse_expr(tokenise('((false) or (true))'))[0]
     self.assertTrue(expr(None))
示例#24
0
    def test_parse_expr_or (self):
        expr = parse_expr(tokenise ('true or true'))[0]
        self.assertTrue(expr (None))

        expr = parse_expr(tokenise ('true or false'))[0]
        self.assertTrue(expr (None))

        expr = parse_expr(tokenise ('false or true'))[0]
        self.assertTrue(expr (None))
        
        expr = parse_expr(tokenise ('false or false'))[0]
        self.assertFalse(expr (None))
        
        expr = parse_expr(tokenise ('false or false or false'))[0]
        self.assertFalse(expr (None))
        
        expr = parse_expr(tokenise ('false or false or true'))[0]
        self.assertTrue(expr (None))
        
        expr = parse_expr(tokenise ('false or true or false'))[0]
        self.assertTrue(expr (None))
        
        expr = parse_expr(tokenise ('true or false or false'))[0]
        self.assertTrue(expr (None))
示例#25
0
    def test_parse_expr_and (self):
        expr = parse_expr(tokenise ('true and true'))[0]
        self.assertTrue(expr (None))

        expr = parse_expr(tokenise ('true and false'))[0]
        self.assertFalse(expr (None))

        expr = parse_expr(tokenise ('false and true'))[0]
        self.assertFalse(expr (None))
        
        expr = parse_expr(tokenise ('false and false'))[0]
        self.assertFalse(expr (None))
        
        expr = parse_expr(tokenise ('true and true and true'))[0]
        self.assertTrue(expr (None))
        
        expr = parse_expr(tokenise ('true and true and false'))[0]
        self.assertFalse(expr (None))
        
        expr = parse_expr(tokenise ('true and false and true'))[0]
        self.assertFalse(expr (None))
        
        expr = parse_expr(tokenise ('false and true and true'))[0]
        self.assertFalse(expr (None))
示例#26
0
    def test_parse_expr_or(self):
        expr = parse_expr(tokenise('true or true'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('true or false'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('false or true'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('false or false'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('false or false or false'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('false or false or true'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('false or true or false'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('true or false or false'))[0]
        self.assertTrue(expr(None))
示例#27
0
    def test_parse_expr_and(self):
        expr = parse_expr(tokenise('true and true'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('true and false'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('false and true'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('false and false'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('true and true and true'))[0]
        self.assertTrue(expr(None))

        expr = parse_expr(tokenise('true and true and false'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('true and false and true'))[0]
        self.assertFalse(expr(None))

        expr = parse_expr(tokenise('false and true and true'))[0]
        self.assertFalse(expr(None))
示例#28
0
 def test_parse_expr_type(self):
     expr = parse_expr(tokenise ('type="Task"'))[0]
     self.assertTrue(expr (Task(flagged=True)))
     self.assertFalse(expr (Project(flagged=True)))
示例#29
0
 def test_parse_expr_string (self):
     expr = parse_expr(tokenise ('"xxx" = "xxx"'))[0]
     self.assertTrue(expr (None))
     expr = parse_expr(tokenise ('"xxx" = "yyy"'))[0]
     self.assertFalse(expr (None))
示例#30
0
 def test_parse_expr_string_regexp(self):
     expr = parse_expr(tokenise('name="bb"'))[0]
     self.assertTrue(expr(Task(name="aabbccdd")))
     self.assertFalse(expr(Task(name="zzz")))
示例#31
0
 def test_parse_expr_unquoted_string_literal(self):
     expr = parse_expr(tokenise('name=aabbccdd'))[0]
     self.assertTrue(expr(Task(name="aabbccdd")))
     self.assertFalse(expr(Task(name="zzz")))
示例#32
0
 def test_parse_expr_status(self):
     expr = parse_expr(tokenise('status="done"'))[0]
     self.assertTrue(expr(Project(status="done")))
     self.assertFalse(expr(Project(status="active")))
示例#33
0
 def test_parse_expr_type(self):
     expr = parse_expr(tokenise('type="Task"'))[0]
     self.assertTrue(expr(Task(flagged=True)))
     self.assertFalse(expr(Project(flagged=True)))
示例#34
0
 def test_parse_expr_unquoted_string_literal(self):
     expr = parse_expr(tokenise ('name=aabbccdd'))[0]
     self.assertTrue(expr (Task(name="aabbccdd")))
     self.assertFalse(expr (Task(name="zzz")))
示例#35
0
 def test_parse_expr_any(self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise('due = any'))[0]
     self.assertFalse(expr(Task(name="")))
     self.assertTrue(expr(Task(name="", date_due=tue)))
示例#36
0
 def test_parse_expr_false (self):
     expr = parse_expr(tokenise ('false'))[0]
     self.assertFalse(expr (None))
示例#37
0
 def test_bug_2013_04_28_2 (self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise ("flagged or (due='to tomorrow')"), now=tue)[0]
     self.assertFalse(expr (Task()))
     self.assertTrue(expr (Task(flagged=True)))
     self.assertTrue(expr (Task(date_due=tue)))
示例#38
0
 def test_parse_expr_string(self):
     expr = parse_expr(tokenise('"xxx" = "xxx"'))[0]
     self.assertTrue(expr(None))
     expr = parse_expr(tokenise('"xxx" = "yyy"'))[0]
     self.assertFalse(expr(None))
示例#39
0
 def test_parse_expr_status(self):
     expr = parse_expr(tokenise ('status="done"'))[0]
     self.assertTrue(expr (Project(status="done")))
     self.assertFalse(expr (Project(status="active")))
示例#40
0
 def test_parse_expr_false(self):
     expr = parse_expr(tokenise('false'))[0]
     self.assertFalse(expr(None))
示例#41
0
 def test_parse_expr_any(self):
     tue = datetime.strptime('Apr 9 2013 11:33PM', '%b %d %Y %I:%M%p')
     expr = parse_expr(tokenise ('due = any'))[0]
     self.assertFalse (expr(Task(name="")))
     self.assertTrue (expr(Task(name="", date_due=tue)))
示例#42
0
 def test_parse_expr_string_regexp(self):
     expr = parse_expr(tokenise ('name="bb"'))[0]
     self.assertTrue(expr (Task(name="aabbccdd")))
     self.assertFalse(expr (Task(name="zzz")))
示例#43
0
 def test_parse_expr_note_filter(self):
     expr = parse_expr(tokenise ('note=123'))[0]
     self.assertTrue(expr (Task(note=TestNote("aaaa123bbb\nccc456ddd"))))
     self.assertTrue(expr (Task(note=TestNote("aaaazzzbbb\nccc123ddd"))))
     self.assertFalse(expr (Task(note=TestNote("z\y\z"))))
     self.assertFalse(expr (Task()))
示例#44
0
 def test_parse_expr_true(self):
     expr = parse_expr(tokenise('true'))[0]
     self.assertTrue(expr(None))
示例#45
0
 def test_parse_expr_note_filter(self):
     expr = parse_expr(tokenise('note=123'))[0]
     self.assertTrue(expr(Task(note=TestNote("aaaa123bbb\nccc456ddd"))))
     self.assertTrue(expr(Task(note=TestNote("aaaazzzbbb\nccc123ddd"))))
     self.assertFalse(expr(Task(note=TestNote("z\y\z"))))
     self.assertFalse(expr(Task()))
示例#46
0
 def test_parse_expr_true (self):
     expr  = parse_expr(tokenise ('true'))[0]
     self.assertTrue(expr (None))