Beispiel #1
0
 def testDontWriteInheritedCategoryBackgroundColor(self):
     parent = category.Category(subject='test', bgColor=wx.RED)
     child = category.Category(subject='child', id='id')
     parent.addChild(child)
     self.categoryContainer.append(parent)
     self.expectInXML('<category creationDateTime="%s" id="id" status="1" '
                      'subject="child" />' % child.creationDateTime())
Beispiel #2
0
 def setUp(self):
     self.category = category.Category(subject='category')
     self.subCategory = category.Category(subject='subcategory')
     self.categorizable = categorizable.CategorizableCompositeObject(
         subject='parent')
     self.child = categorizable.CategorizableCompositeObject(
         subject='child')
 def addMutualExclusiveSubcategories(self, parentCategory):
     subCategory1 = category.Category('subCategory1')
     subCategory2 = category.Category('subCategory2')
     parentCategory.addChild(subCategory1)
     parentCategory.addChild(subCategory2)
     parentCategory.makeSubcategoriesExclusive()
     return subCategory1, subCategory2
Beispiel #4
0
 def setUp(self):
     self.categories = category.CategoryList()
     self.category1 = category.Category('Category 1')
     self.category2 = category.Category('Category 2')
     self.viewerContainer = MockViewerContainer()
     self.menu = gui.menu.ToggleCategoryMenu(self.frame, self.categories,
                                             self.viewerContainer)
Beispiel #5
0
 def setUp(self):
     super(DragAndDropCategoryCommandTest, self).setUp()
     self.parent = category.Category('parent')
     self.child = category.Category('child')
     self.grandchild = category.Category('grandchild')
     self.parent.addChild(self.child)
     self.child.addChild(self.grandchild)
     self.categories.extend([self.parent, self.child])
Beispiel #6
0
 def testSubCategoryWithoutTasks(self):
     parentCategory = category.Category(subject='parent')
     childCategory = category.Category(subject='child')
     parentCategory.addChild(childCategory)
     self.categoryContainer.extend([parentCategory, childCategory])
     self.expectInXML('<category id="%s" status="1" subject="parent">\n'
                      '<category id="%s" status="1" subject="child"/>\n</category>'%\
                      (parentCategory.id(), childCategory.id()))
Beispiel #7
0
 def testAddCategoryWithParentWithFont(self):
     self.registerObserver(self.fontChangedEventType)
     parentCategory = category.Category('Parent')
     parentCategory.setFont(wx.SWISS_FONT)
     childCategory = category.Category('Child')
     parentCategory.addChild(childCategory)
     childCategory.setParent(parentCategory)
     self.categorizable.addCategory(childCategory)
     self.assertEqual(1, len(self.events))
Beispiel #8
0
 def testAddCategoryWithParentWithIcon(self):
     self.registerObserver(self.iconChangedEventType)
     parentCategory = category.Category('Parent')
     parentCategory.setIcon('icon')
     childCategory = category.Category('Child')
     parentCategory.addChild(childCategory)
     childCategory.setParent(parentCategory)
     self.categorizable.addCategory(childCategory)
     self.assertEqual(1, len(self.events))
Beispiel #9
0
 def testAddCategoryWithParentWithBackgroundColor(self):
     self.registerObserver(self.backgroundColorChangedEventType)
     parentCategory = category.Category('Parent')
     parentCategory.setBackgroundColor(wx.RED)
     childCategory = category.Category('Child')
     parentCategory.addChild(childCategory)
     childCategory.setParent(parentCategory)
     self.categorizable.addCategory(childCategory)
     self.assertEqual(1, len(self.events))
Beispiel #10
0
 def testSortByCategories_WhenParentCategoryEqualsChildCategoryOfAnotherParent(self):
     category1 = category.Category('Category 1')
     category2 = category.Category('Category 2')
     category3 = category.Category('Category 3')
     self.child1.addCategory(category1)
     self.parent1.addCategory(category3)
     self.parent2.addCategory(category2)
     self.sorter.sortBy('categories')
     self.failUnless(list(self.sorter).index(self.parent2) < \
         list(self.sorter).index(self.parent1))
Beispiel #11
0
 def testDeleteTaskWithTwoCategories(self):
     cat1 = category.Category('category 1')
     cat2 = category.Category('category 2')
     self.categories.extend([cat1, cat2])
     for cat in cat1, cat2:
         cat.addCategorizable(self.task1)
         self.task1.addCategory(cat)
     self.delete('all')
     self.assertDoUndoRedo(lambda: self.failIf(cat1.categorizables() or cat2.categorizables()), 
         lambda: self.failUnless(set([self.task1]) == cat1.categorizables() == cat2.categorizables()))
Beispiel #12
0
 def testMutualExclusiveSubcategoriesWithSubcategories(self):
     self.category1.makeSubcategoriesExclusive()
     self.setUpSubcategories()
     category3 = category.Category('Category 3')
     self.category1.addChild(category3)
     category4 = category.Category('Category 4')
     category3.addChild(category4)
     subMenuItems = self.menu.GetMenuItems()[2].GetSubMenu().GetMenuItems()
     checkedItems = [item for item in subMenuItems if item.IsChecked()]
     self.failIf(checkedItems)
 def testFilterOnAnyCategory(self):
     cat1 = category.Category('category 1')
     cat2 = category.Category('category 2')
     self.note.addCategory(cat1)
     cat1.addCategorizable(self.note)
     self.taskFile.categories().extend([cat1, cat2])
     cat1.setFiltered(True)
     cat2.setFiltered(True)
     self.assertEqual(1, self.viewer.size())
     self.settings.setboolean('view', 'categoryfiltermatchall', False)
     self.assertEqual(1, self.viewer.size())
Beispiel #14
0
 def testSubCategoryWithoutTasks(self):
     parent = category.Category(subject='parent')
     child = category.Category(subject='child')
     parent.addChild(child)
     self.categoryContainer.extend([parent, child])
     self.expectInXML('<category creationDateTime="%s" id="%s" '
                      'status="1" subject="parent">\n'
                      '<category creationDateTime="%s" id="%s" status="1" '
                      'subject="child" />\n</category>'%\
                      (parent.creationDateTime(), parent.id(),
                       child.creationDateTime(), child.id()))
Beispiel #15
0
 def testSubCategoryWithOneTask(self):
     parentCategory = category.Category(subject='parent')
     childCategory = category.Category(subject='child',
                                       categorizables=[self.task])
     parentCategory.addChild(childCategory)
     self.categoryContainer.extend([parentCategory, childCategory])
     self.expectInXML(
         '<category id="%s" status="1" subject="parent">\n'
         '<category categorizables="%s" id="%s" status="1" subject="child"/>\n'
         '</category>' %
         (parentCategory.id(), self.task.id(), childCategory.id()))
Beispiel #16
0
 def testDeleteParentAndChildWhenParentAndChildBelongToDifferentCategories(self):
     cat1 = category.Category('category 1')
     cat2 = category.Category('category 2')
     self.categories.extend([cat1, cat2])
     cat1.addCategorizable(self.child)
     self.child.addCategory(cat1)
     cat2.addCategorizable(self.parent)
     self.parent.addCategory(cat2)
     self.delete([self.parent])
     self.assertDoUndoRedo(lambda: self.failIf(cat1.categorizables() or cat2.categorizables()), 
         lambda: self.failUnless(set([self.child]) == cat1.categorizables() and \
                                 set([self.parent]) == cat2.categorizables()))
Beispiel #17
0
 def testSubcontext(self):
     work = category.Category(subject='@Work')
     staff_meeting = category.Category(subject='Staff meeting')
     work.addChild(staff_meeting)
     self.taskFile.categories().append(work)
     discuss_proposal = task.Task(subject='Discuss the proposal')
     self.taskFile.tasks().append(discuss_proposal)
     discuss_proposal.addCategory(staff_meeting)
     staff_meeting.addCategorizable(discuss_proposal)
     self.writer.write(self.viewer, self.settings, False)
     self.assertEqual('Discuss the proposal @Work->Staff_meeting\n',
                      self.file.getvalue())
Beispiel #18
0
 def testMultipleContexts(self):
     phone = category.Category(subject='@phone')
     food = category.Category(subject='@food')
     self.taskFile.categories().extend([phone, food])
     pizza = task.Task(subject='Order pizza')
     self.taskFile.tasks().append(pizza)
     phone.addCategorizable(pizza)
     pizza.addCategory(phone)
     food.addCategorizable(pizza)
     pizza.addCategory(food)
     self.writer.write(self.viewer, self.settings, False)
     self.assertEqual('Order pizza @food @phone\n', self.file.getvalue())
Beispiel #19
0
 def testSortByCategories(self):
     cat0 = category.Category(subject='Category 0')
     cat1 = category.Category(subject='Category 1')
     task0 = task.Task(subject='0')
     task1 = task.Task(subject='1')
     task0.addCategory(cat1)
     cat1.addCategorizable(task0)
     task1.addCategory(cat0)
     cat0.addCategorizable(task1)
     self.taskList.extend([task0, task1])
     self.assertItems(task0, task1)
     self.viewer.sortBy('categories')
     self.assertItems(task1, task0)
Beispiel #20
0
 def testSubCategoryWithOneTask(self):
     parent = category.Category(subject='parent')
     child = category.Category(subject='child', categorizables=[self.task])
     parent.addChild(child)
     self.categoryContainer.extend([parent, child])
     self.expectInXML(
         '<category creationDateTime="%s" id="%s" '
         'status="1" subject="parent">\n'
         '<category categorizables="%s" creationDateTime="%s" '
         'id="%s" status="1" subject="child" />\n'
         '</category>' %
         (parent.creationDateTime(), parent.id(), self.task.id(),
          child.creationDateTime(), child.id()))
Beispiel #21
0
 def setUp(self):
     task.Task.settings = config.Settings(load=False)
     self.parent = task.Task('parent')
     self.parentCategory = category.Category('parent')
     self.parentCategory.addCategorizable(self.parent)
     self.child = task.Task()
     self.childCategory = category.Category('child')
     self.childCategory.addCategorizable(self.child)
     self.parent.addChild(self.child)
     self.unusedCategory = category.Category('unused')
     self.list = task.TaskList([self.parent, self.child])
     self.categories = category.CategoryList(
         [self.parentCategory, self.childCategory, self.unusedCategory])
     self.filter = category.filter.CategoryFilter(
         self.list, categories=self.categories, treeMode=self.treeMode)
Beispiel #22
0
 def testSaveSelectionAddsParentCategoriesWhenSubcategoriesAreUsed(self):
     task1 = task.Task()
     self.taskFile.tasks().extend([task1])
     aCategory = category.Category('A category')
     aSubCategory = category.Category('A subcategory')
     aCategory.addChild(aSubCategory)
     self.taskFile.categories().append(aCategory)
     task1.addCategory(aSubCategory)
     aSubCategory.addCategorizable(task1)
     self.iocontroller.saveselection(tasks=self.taskFile.tasks(),
                                     filename=self.filename1)
     taskFile = persistence.TaskFile()
     taskFile.setFilename(self.filename1)
     taskFile.load()
     self.assertEqual(2, len(taskFile.categories()))
Beispiel #23
0
 def _read(self, *args, **kwargs):  # pylint: disable=W0613,W0221
     if self._throw:
         raise IOError
     else:
         return [task.Task()], [category.Category('category')], [], None, {
             self.monitor().guid(): self.monitor()
         }, None
Beispiel #24
0
 def testRenderMultipleCategories(self):
     for index in range(1, 3):
         cat = category.Category(subject='Category %d' % index)
         self.task.addCategory(cat)
         cat.addCategorizable(self.task)
     self.assertEqual('Category 1, Category 2',
                      self.viewer.renderCategories(self.task))
Beispiel #25
0
 def testCategoryBackgroundColor(self):
     cat = category.Category('category with background color',
                             bgColor=self.newColor)
     cat.addCategorizable(self.task)
     self.task.addCategory(cat)
     self.taskList.append(self.task)
     self.assertBackgroundColor()
Beispiel #26
0
 def testNewItem(self):
     self.taskFile.categories().append(
         category.Category('cat', filtered=True))
     dialog = self.viewer.newItemDialog(bitmap='new')
     tree = dialog._interior[4].viewer.widget
     firstChild = tree.GetFirstChild(tree.GetRootItem())[0]
     self.failUnless(firstChild.IsChecked())
 def testShowCategoriesColumn(self):
     newCategory = category.Category('Category')
     self.taskFile.categories().append(newCategory)
     self.note.addCategory(newCategory)
     newCategory.addCategorizable(self.note)
     self.viewer.showColumnByName('categories')
     self.assertEqual('Category', self.firstItemText(column=3))
Beispiel #28
0
 def testCategoryWithOneAttachment(self):
     cat = category.Category('cat')
     self.categoryContainer.append(cat)
     cat.addAttachments(attachment.FileAttachment('whatever.txt', id='foo'))
     self.expectInXML(
         '<attachment id="foo" location="whatever.txt" status="1" subject="whatever.txt" type="file"/>'
     )
Beispiel #29
0
 def testCategoryWithDeletedTask(self):
     aCategory = category.Category(subject='category',
                                   categorizables=[self.task],
                                   id='id')
     self.categoryContainer.append(aCategory)
     self.taskList.remove(self.task)
     self.expectInXML('<category id="id" status="1" subject="category"/>')
Beispiel #30
0
 def testFilteredCategory(self):
     filteredCategory = category.Category(subject='test',
                                          filtered=True,
                                          id='id')
     self.categoryContainer.extend([filteredCategory])
     self.expectInXML(
         '<category filtered="True" id="id" status="1" subject="test"/>')