コード例 #1
0
    def test_load_note_attribs(self):
        task = Task()
        n_attribs_before = len(task.attribs)
        load_note_attribs(task, "")
        self.assertEqual(n_attribs_before, len(task.attribs))

        n_attribs_before = len(task.attribs)
        task = Task(note=TestNote("xyz"))
        self.assertEqual(n_attribs_before, len(task.attribs))

        task = Task(note=TestNote("%of cal xxx"))
        load_note_attribs(task, "")
        self.assertEquals(True, task.attribs['xxx'])

        task = Task(note=TestNote("%of cal xxx\n%of cal yyy"))
        load_note_attribs(task, "")
        self.assertEquals(True, task.attribs['xxx'])
        self.assertEquals(True, task.attribs['yyy'])

        task = Task(note=TestNote("%of cal xxx   yyy zzz   "))
        n_attribs_before = len(task.attribs)
        load_note_attribs(task, "")
        self.assertEquals(True, task.attribs['xxx'])
        self.assertEquals(True, task.attribs['yyy'])
        self.assertEquals(True, task.attribs['zzz'])
        self.assertEqual(n_attribs_before + 3, len(task.attribs))
コード例 #2
0
ファイル: cmd_parser_test.py プロジェクト: prateek/ofexport
 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)))
コード例 #3
0
ファイル: plugin_ics_test.py プロジェクト: alainyog/ofexport
    def test_format_alarm (self):
        task = Task ()
        self.assertEquals ("BEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:OmniFocus Reminder\nTRIGGER:-PT0M\nEND:VALARM\n", format_alarm (task))
        
        task.attribs['noalarm'] = True
        self.assertEquals ("", format_alarm (task))

        
コード例 #4
0
 def test_TaskNameFilterVisitor_exclude(self):
     n1 = Task(name=u'n1')
     n2 = Task(name=u'n2 xxx')
     nodes = [n1, n2]
     visitor = TaskNameFilterVisitor('xxx', include=False)
     traverse_list(visitor, nodes)
     self.assertTrue(n1.marked)
     self.assertFalse(n2.marked)
コード例 #5
0
    def test_format_alarm(self):
        task = Task()
        self.assertEquals(
            "BEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:OmniFocus Reminder\nTRIGGER:-PT0M\nEND:VALARM\n",
            format_alarm(task))

        task.attribs['noalarm'] = True
        self.assertEquals("", format_alarm(task))
コード例 #6
0
ファイル: visitors_test.py プロジェクト: tmarkiewicz/ofexport
 def test_TaskNameFilterVisitor_include_ignores_children (self):
     n1 = Task (name=u'n1 xxx')
     n2 = Task (name=u'n2')
     n1.add_child(n2)
     
     visitor = TaskNameFilterVisitor ('xxx')
     traverse (visitor, n1)
     self.assertTrue(n1.marked)
     self.assertTrue(n2.marked)
コード例 #7
0
ファイル: omnifocus.py プロジェクト: McPolemic/ofexport
 def __init__(self, ofattribs):
     Task.__init__(self,
                   name=ofattribs['name'],
                   date_completed = datetimeFromAttrib (ofattribs,'dateCompleted'),
                   date_to_start = datetimeFromAttrib (ofattribs,'dateToStart'),
                   date_due = datetimeFromAttrib (ofattribs,'dateDue'),
                   flagged = bool (ofattribs['flagged']),
                   context=None)
     self.ofattribs = ofattribs
コード例 #8
0
    def test_TaskNameFilterVisitor_include_ignores_children(self):
        n1 = Task(name=u'n1 xxx')
        n2 = Task(name=u'n2')
        n1.add_child(n2)

        visitor = TaskNameFilterVisitor('xxx')
        traverse(visitor, n1)
        self.assertTrue(n1.marked)
        self.assertTrue(n2.marked)
コード例 #9
0
ファイル: visitors_test.py プロジェクト: prateek/ofexport
 def test_TaskNameFilterVisitor_exclude(self):
     n1 = Task(name=u'n1')
     n2 = Task(name=u'n2 xxx')
     nodes = [n1, n2]
     visitor = Filter([PROJECT, CONTEXT, TASK, FOLDER],
                      lambda x: match_name(x, 'xxx'), False, 'pretty')
     traverse_list(visitor, nodes)
     self.assertTrue(n1.marked)
     self.assertFalse(n2.marked)
コード例 #10
0
 def test_TaskNameFilterVisitor_include_ignores_children (self):
     n1 = Task (name=u'n1 xxx')
     n2 = Task (name=u'n2')
     n1.add_child(n2)
     
     visitor = Filter ([PROJECT, CONTEXT, TASK, FOLDER], lambda x: match_name(x, 'xxx'), True, 'pretty')
     traverse (visitor, n1)
     self.assertTrue(n1.marked)
     self.assertTrue(n2.marked)
コード例 #11
0
ファイル: visitors_test.py プロジェクト: prateek/ofexport
    def test_TaskNameFilterVisitor_include_ignores_children(self):
        n1 = Task(name=u'n1 xxx')
        n2 = Task(name=u'n2')
        n1.add_child(n2)

        visitor = Filter([PROJECT, CONTEXT, TASK, FOLDER],
                         lambda x: match_name(x, 'xxx'), True, 'pretty')
        traverse(visitor, n1)
        self.assertTrue(n1.marked)
        self.assertTrue(n2.marked)
コード例 #12
0
ファイル: visitors_test.py プロジェクト: prateek/ofexport
    def test_Sort_same_use_underlying_order_out_of_order(self):
        n1 = Task(name=u'aaa', order=2)
        n2 = Task(name=u'aaa', order=1)
        root = Project(name=u'r')
        root.add_child(n1)
        root.add_child(n2)

        visitor = Sort([PROJECT], lambda x: x.name, 'pretty')
        traverse(visitor, root)
        self.assertIs(root.children[0], n2)
        self.assertIs(root.children[1], n1)
コード例 #13
0
ファイル: visitors_test.py プロジェクト: prateek/ofexport
    def test_Sort_in_order(self):
        n1 = Task(name=u'a n1')
        n2 = Task(name=u'b n2')
        root = Project(name=u'r')
        root.add_child(n1)
        root.add_child(n2)

        visitor = Sort([PROJECT], lambda x: x.name, 'pretty')
        traverse(visitor, root)
        self.assertIs(root.children[0], n1)
        self.assertIs(root.children[1], n2)
コード例 #14
0
 def __init__(self, ofattribs):
     Task.__init__(self,
                   name=ofattribs['name'],
                   date_completed=datetimeFromAttrib(
                       ofattribs, 'dateCompleted'),
                   date_to_start=datetimeFromAttrib(ofattribs,
                                                    'dateToStart'),
                   date_due=datetimeFromAttrib(ofattribs, 'dateDue'),
                   flagged=bool(ofattribs['flagged']),
                   context=None)
     self.ofattribs = ofattribs
コード例 #15
0
 def test_traverse_task_when_not_marked (self):
     parent = Task (name=u'p')
     n1 = Task (name=u'n1')
     n2 = Task (name=u'n2')
     parent.children.append (n1)
     parent.children.append (n2)
     parent.marked = False
     
     visitor = DemoVisitor ()
     traverse (visitor, parent)
     self.assertEqual(0, len(visitor.tasks_started))
     self.assertEqual(0, len(visitor.tasks_ended))
コード例 #16
0
    def test_traverse_task_when_not_marked(self):
        parent = Task(name=u'p')
        n1 = Task(name=u'n1')
        n2 = Task(name=u'n2')
        parent.children.append(n1)
        parent.children.append(n2)
        parent.marked = False

        visitor = DemoVisitor()
        traverse(visitor, parent)
        self.assertEqual(0, len(visitor.tasks_started))
        self.assertEqual(0, len(visitor.tasks_ended))
コード例 #17
0
    def test_load_note_attribs_with_default(self):
        task = Task()
        n_attribs_before = len(task.attribs)
        load_note_attribs(task, "%of cal in_default")
        self.assertEquals(True, task.attribs['in_default'])
        self.assertEqual(n_attribs_before + 1, len(task.attribs))

        task = Task(note=TestNote("%of cal in_note"))
        n_attribs_before = len(task.attribs)
        load_note_attribs(task, "%of cal in_default")
        self.assertEquals(True, task.attribs['in_note'])
        self.assertEqual(n_attribs_before + 1, len(task.attribs))
コード例 #18
0
    def test_sort_no_key_defined(self):
        parent = Task(name=u'p')
        n1 = Task(name=u'n1')
        n2 = Task(name=u'n2')
        parent.children.append(n1)
        parent.children.append(n2)

        try:
            sort([parent])
            self.fail('exception expected')
        except Exception as e:
            self.assertEquals("not implemented in <class 'treemodel.Task'>",
                              e.message)
コード例 #19
0
    def test_convert_attribute(self):
        type_fns = {}
        type_fns['string'] = lambda x: x

        conversion = Conversion("nosuchconversion", "default value",
                                "($value)", "string")
        self.assertEquals("default value", conversion.value(Task(), type_fns))

        conversion = Conversion("name", "default value", "($value)", "string")
        self.assertEquals("default value", conversion.value(Task(), type_fns))

        conversion = Conversion("name", "default value", "($value)", "string")
        self.assertEquals("(123)", conversion.value(Task(name="123"),
                                                    type_fns))
コード例 #20
0
ファイル: treemodel_test.py プロジェクト: alainyog/ofexport
 def test_project_add_child (self):
     project = Project ()
     child = Task ()
     project.add_child (child)
     self.assertEquals(project, child.parent)
     self.assertEquals(project, child.project)
     
     project = Project ()
     child = Task ()
     grandchild = Task ()
     child.add_child (grandchild)
     project.add_child (child)
     self.assertEquals(project, child.parent)
     self.assertEquals(project, child.project)
     self.assertEquals(project, grandchild.project)
コード例 #21
0
ファイル: omnifocus.py プロジェクト: markokaestner/ofexport
 def __init__(self, ofattribs):
     Task.__init__(self,
                   name=ofattribs['name'],
                   date_completed = datetimeFromAttrib (ofattribs,'dateCompleted'),
                   date_to_start = datetimeFromAttrib (ofattribs,'dateToStart'),
                   date_due = datetimeFromAttrib (ofattribs,'dateDue'),
                   flagged = bool (ofattribs['flagged']),
                   context=None)
     self.ofattribs = ofattribs
     if 'persistentIdentifier' in ofattribs:
         self.link = 'omnifocus:///task/' + ofattribs['persistentIdentifier']
     noteXMLData = ofattribs['noteXMLData']
     if noteXMLData != None:
         self.note = OFNote (self, noteXMLData)
     logger.debug ('loaded task: %s %s', self.id, self.name)
コード例 #22
0
    def test_traverse_list_tasks(self):
        n1 = Task(name=u'n1')
        n2 = Task(name=u'n2')
        nodes = [n1, n2]
        visitor = DemoVisitor()
        traverse_list(visitor, nodes)
        self.assertEqual(2, len(visitor.tasks_started))
        self.assertTrue(n1 in visitor.tasks_started)
        self.assertTrue(n2 in visitor.tasks_started)

        self.assertEqual(2, len(visitor.tasks_ended))
        self.assertTrue(n1 in visitor.tasks_ended)
        self.assertTrue(n2 in visitor.tasks_ended)

        self.assertEqual(0, len(visitor.projects_started))
        self.assertEqual(0, len(visitor.folders_started))
        self.assertEqual(0, len(visitor.contexts_started))
コード例 #23
0
ファイル: plugin_ics_test.py プロジェクト: alainyog/ofexport
 def test_format_date (self):
     wed = dateutil.parser.parse('Wed, 27 Oct 2010 22:17:00 BST')
     thu = dateutil.parser.parse('Thu, 28 Oct 2010 22:17:00 BST')
     
     task = Task (date_to_start=wed, date_due=thu)
     self.assertEquals ("20101027T211700Z", format_date (task, task.date_to_start, False))
     self.assertEquals ("20101028T211700Z", format_date (task, task.date_due, True))
     
     task = Task (date_to_start=wed, date_due=thu)
     task.attribs["allday"] = True
     self.assertEquals ("20101027", format_date (task, task.date_to_start, False))
     self.assertEquals ("20101029", format_date (task, task.date_due, True))
     
     wed1 = dateutil.parser.parse('Wed, 27 Oct 2010 00:00:00 BST')
     wed2 = dateutil.parser.parse('Wed, 27 Oct 2010 23:59:59 BST')
     task = Task (date_to_start=wed1, date_due=wed2)
     task.attribs["allday"] = True
     self.assertEquals ("20101027", format_date (task, task.date_to_start, False))
     self.assertEquals ("20101028", format_date (task, task.date_due, True))
     
     wed1 = dateutil.parser.parse('Wed, 27 Oct 2010 00:00:00 BST')
     wed2 = dateutil.parser.parse('Wed, 28 Oct 2010 00:00:00 BST')
     task = Task (date_to_start=wed1, date_due=wed2)
     task.attribs["allday"] = True
     self.assertEquals ("20101027", format_date (task, task.date_to_start, False))
     self.assertEquals ("20101029", format_date (task, task.date_due, True))
コード例 #24
0
    def test_traverse_task(self):
        parent = Task(name=u'p')
        n1 = Task(name=u'n1')
        n2 = Task(name=u'n2')
        parent.children.append(n1)
        parent.children.append(n2)

        visitor = DemoVisitor()
        traverse(visitor, parent)
        self.assertEqual(3, len(visitor.tasks_started))
        self.assertTrue(parent in visitor.tasks_started)
        self.assertTrue(n1 in visitor.tasks_started)
        self.assertTrue(n2 in visitor.tasks_started)

        self.assertEqual(3, len(visitor.tasks_ended))
        self.assertTrue(parent in visitor.tasks_ended)
        self.assertTrue(n1 in visitor.tasks_ended)
        self.assertTrue(n2 in visitor.tasks_ended)
コード例 #25
0
 def test_load_note_due_attrib(self):
     the_date = dateutil.parser.parse('Wed, 27 Oct 2010 22:17:00 BST')
     task = Task(date_to_start=the_date,
                 date_due=the_date,
                 note=TestNote("%of cal due=23:12"))
     load_note_attribs(task, "")
     self.assertEqual("2010.10.27 22:17",
                      task.date_to_start.strftime('%Y.%m.%d %H:%M'))
     self.assertEqual("2010.10.27 23:12",
                      task.date_due.strftime('%Y.%m.%d %H:%M'))
コード例 #26
0
ファイル: cmd_parser_test.py プロジェクト: prateek/ofexport
 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)))
コード例 #27
0
    def test_context_add_child(self):
        context = Context()
        child = Context()
        context.add_child(child)
        self.assertEquals(context, child.parent)

        context = Context()
        child = Task()
        context.add_child(child)
        self.assertEquals(context, child.context)
        self.assertEquals(None, child.parent)
コード例 #28
0
ファイル: omnifocus.py プロジェクト: prateek/ofexport
 def __init__(self, ofattribs):
     Task.__init__(
         self,
         name=ofattribs['name'],
         date_completed=datetimeFromAttrib(ofattribs, 'dateCompleted'),
         date_to_start=datetimeFromAttrib(ofattribs, 'dateToStart'),
         date_due=datetimeFromAttrib(ofattribs, 'dateDue'),
         date_added=datetimeFromAttrib(ofattribs, 'dateAdded'),
         estimated_minutes=intFromAttrib(ofattribs, 'estimatedMinutes'),
         flagged=bool(ofattribs['flagged']),
         context=None)
     self.ofattribs = ofattribs
     self.order = ofattribs['rank']
     if 'persistentIdentifier' in ofattribs:
         self.id = ofattribs['persistentIdentifier']
         self.link = 'omnifocus:///task/' + ofattribs['persistentIdentifier']
     noteXMLData = ofattribs['noteXMLData']
     if noteXMLData != None:
         self.note = OFNote(self, noteXMLData)
     logger.debug('loaded task: %s %s', self.id, self.name)
コード例 #29
0
    def test_fix_dates(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')

        task = Task()
        fix_dates(task)
        self.assertEquals(None, task.date_to_start)
        self.assertEquals(None, task.date_due)

        task = Task(date_to_start=tue)
        fix_dates(task)
        self.assertEquals(tue, task.date_to_start)
        self.assertEquals(tue, task.date_due)

        task = Task(date_due=tue)
        fix_dates(task)
        self.assertEquals(tue, task.date_to_start)
        self.assertEquals(tue, task.date_due)

        task = Task(date_to_start=tue, date_due=wed)
        fix_dates(task)
        self.assertEquals(tue, task.date_to_start)
        self.assertEquals(wed, task.date_due)
コード例 #30
0
ファイル: cmd_parser_test.py プロジェクト: prateek/ofexport
    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)))
コード例 #31
0
    def test_project_add_child(self):
        project = Project()
        child = Task()
        project.add_child(child)
        self.assertEquals(project, child.parent)
        self.assertEquals(project, child.project)

        project = Project()
        child = Task()
        grandchild = Task()
        child.add_child(grandchild)
        project.add_child(child)
        self.assertEquals(project, child.parent)
        self.assertEquals(project, child.project)
        self.assertEquals(project, grandchild.project)
コード例 #32
0
ファイル: visitors_test.py プロジェクト: prateek/ofexport
    def test_Scenario_4(self):
        '''
        In context mode select a single deeply nested task for exclusion
        '''
        f1 = Folder(name='1')
        p1 = Project(name='2', parent=f1)
        t1 = Task(name='3', parent=p1)
        t2_selected = Task(name='xxx', parent=t1)
        t3 = Task(name='5', parent=t2_selected)
        t4 = Task(name='3', parent=t1)

        f2 = Folder(name='1', parent=f1)
        p2 = Project(name='2', parent=f2)
        t5 = Task(name='3', parent=p2)
        t6 = Task(name='3', parent=t5)
        t7 = Task(name='5', parent=t6)

        c1_on_path = Context(name='6')
        c2_on_path = Context(name='6', parent=c1_on_path)
        c2_on_path.add_child(t2_selected)

        c3 = Context(name='7', parent=c2_on_path)

        traverse_list(Filter([PROJECT, CONTEXT, TASK, FOLDER],
                             lambda x: match_name(x, 'xxx'), False, 'pretty'),
                      [c1_on_path],
                      project_mode=False)

        self.assertTrue(f1.marked)
        self.assertTrue(p1.marked)
        self.assertTrue(t1.marked)
        self.assertFalse(t2_selected.marked)
        self.assertTrue(t3.marked)
        self.assertTrue(t4.marked)
        self.assertTrue(t5.marked)
        self.assertTrue(t6.marked)
        self.assertTrue(t7.marked)
        self.assertTrue(f2.marked)
        self.assertTrue(p2.marked)
        self.assertTrue(t5.marked)
        self.assertTrue(t6.marked)
        self.assertTrue(t7.marked)

        self.assertTrue(c1_on_path.marked)
        self.assertTrue(c2_on_path.marked)
        self.assertTrue(c3.marked)
コード例 #33
0
ファイル: visitors_test.py プロジェクト: prateek/ofexport
    def test_Scenario_2(self):
        '''
        In project mode select a single deeply nested task for exclusion
        '''
        f_on_path = Folder(name='1')
        p_on_path = Project(name='2', parent=f_on_path)
        t1_on_path = Task(name='3', parent=p_on_path)
        t2_selected = Task(name='xxx', parent=t1_on_path)
        t3_on_path = Task(name='5', parent=t2_selected)
        t4 = Task(name='3', parent=t1_on_path)

        f = Folder(name='1', parent=f_on_path)
        p = Project(name='2', parent=f)
        t1 = Task(name='3', parent=p)
        t2 = Task(name='3', parent=t1)
        t3 = Task(name='5', parent=t2)

        c1 = Context(name='6')
        c1.add_child(t2_selected)

        c2 = Context(name='7')
        c2.add_child(t3)

        traverse_list(
            Filter([PROJECT, CONTEXT, TASK, FOLDER],
                   lambda x: match_name(x, 'xxx'), False, 'pretty'),
            [f_on_path])

        self.assertTrue(f_on_path.marked)
        self.assertTrue(p_on_path.marked)
        self.assertTrue(t1_on_path.marked)
        self.assertFalse(t2_selected.marked)
        self.assertFalse(t3_on_path.marked)

        self.assertTrue(c1.marked)
        self.assertTrue(c2.marked)

        self.assertTrue(f.marked)
        self.assertTrue(p.marked)
        self.assertTrue(t1.marked)
        self.assertTrue(t2.marked)
        self.assertTrue(t3.marked)
        self.assertTrue(t4.marked)
コード例 #34
0
ファイル: plugin_json.py プロジェクト: prateek/ofexport
def load_from_json(json_data, item_db):
    if 'ref' in json_data:
        item = item_db[json_data['ref']]
        return item

    item_type = json_data['type']
    item_id = json_data['id']
    if item_type == FOLDER:
        item = Folder()
    elif item_type == CONTEXT:
        item = Context()
    elif item_type == TASK:
        item = Task()
    elif item_type == PROJECT:
        item = Project()
    load_attrib(item, 'id', json_data, lambda x: x)
    load_attrib(item, 'link', json_data, lambda x: x)
    load_attrib(item, 'status', json_data, lambda x: x)
    load_attrib(item, 'name', json_data, lambda x: x)
    load_attrib(item, 'date_completed', json_data,
                lambda x: datetime.strptime(x, TIME_FMT))
    load_attrib(item, 'date_to_start', json_data,
                lambda x: datetime.strptime(x, TIME_FMT))
    load_attrib(item, 'date_due', json_data,
                lambda x: datetime.strptime(x, TIME_FMT))
    load_attrib(item, 'flagged', json_data, lambda x: x)
    load_attrib(item, 'next', json_data, lambda x: x)
    load_attrib(item, 'note', json_data, lambda x: JSONNote(x))
    load_attrib(item, 'order', json_data, lambda x: x)

    for child_data in json_data['children']:
        child = load_from_json(child_data, item_db)
        item.add_child(child)

    item_db[item_id] = item
    return item
コード例 #35
0
 def test_build_attribute_map(self):
     builder = AttribMapBuilder()
     values = builder.get_values(Task(name="123"))
     self.assertEqual("123", values["name"])
コード例 #36
0
    def test_format_date(self):
        wed = dateutil.parser.parse('Wed, 27 Oct 2010 22:17:00 BST')
        thu = dateutil.parser.parse('Thu, 28 Oct 2010 22:17:00 BST')

        task = Task(date_to_start=wed, date_due=thu)
        self.assertEquals("20101027T211700Z",
                          format_date(task, task.date_to_start, False))
        self.assertEquals("20101028T211700Z",
                          format_date(task, task.date_due, True))

        task = Task(date_to_start=wed, date_due=thu)
        task.attribs["allday"] = True
        self.assertEquals("20101027",
                          format_date(task, task.date_to_start, False))
        self.assertEquals("20101029", format_date(task, task.date_due, True))

        wed1 = dateutil.parser.parse('Wed, 27 Oct 2010 00:00:00 BST')
        wed2 = dateutil.parser.parse('Wed, 27 Oct 2010 23:59:59 BST')
        task = Task(date_to_start=wed1, date_due=wed2)
        task.attribs["allday"] = True
        self.assertEquals("20101027",
                          format_date(task, task.date_to_start, False))
        self.assertEquals("20101028", format_date(task, task.date_due, True))

        wed1 = dateutil.parser.parse('Wed, 27 Oct 2010 00:00:00 BST')
        wed2 = dateutil.parser.parse('Wed, 28 Oct 2010 00:00:00 BST')
        task = Task(date_to_start=wed1, date_due=wed2)
        task.attribs["allday"] = True
        self.assertEquals("20101027",
                          format_date(task, task.date_to_start, False))
        self.assertEquals("20101029", format_date(task, task.date_due, True))
コード例 #37
0
ファイル: cmd_parser_test.py プロジェクト: prateek/ofexport
 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)))
コード例 #38
0
ファイル: treemodel_test.py プロジェクト: alainyog/ofexport
 def test_task_add_child (self):
     project = Project ()
     task = Task ()
     child = Task ()
     project.add_child (task)
     task.add_child (child)
     self.assertEquals(task, child.parent)
     self.assertEquals(project, child.project)
     
     project = Project ()
     task = Task ()
     child = Task ()
     grandchild = Task ()
     project.add_child (task)
     task.add_child (child)
     child.add_child (grandchild)
     task.add_child (child)
     self.assertEquals(task, child.parent)
     self.assertEquals(project, child.project)
     self.assertEquals(child, grandchild.parent)
     self.assertEquals(project, grandchild.project)
コード例 #39
0
ファイル: cmd_parser_test.py プロジェクト: prateek/ofexport
 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()))