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())
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
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)
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])
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()))
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))
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))
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))
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))
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()))
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())
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()))
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()))
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()))
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())
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())
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)
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()))
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)
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()))
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
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))
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()
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))
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"/>' )
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"/>')
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"/>')