Пример #1
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')
Пример #2
0
 def testGrandChildCategoryIncludedInGrandParentDownwardRecursiveCategories(
         self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     grandchild = categorizable.CategorizableCompositeObject()
     child.addChild(grandchild)
     grandchild.addCategory(self.category)
     self.assertEqual(set([self.category]),
                      self.categorizable.categories(recursive=True))
Пример #3
0
 def testGrandParentAndParentCategoriesIncludedInGrandChildUpwardRecursiveCategories(
         self):
     self.categorizable.addCategory(self.category)
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     grandchild = categorizable.CategorizableCompositeObject()
     child.addChild(grandchild)
     childCategory = category.Category('Child category')
     child.addCategory(childCategory)
     self.assertEqual(set([self.category, childCategory]),
                      grandchild.categories(recursive=True, upwards=True))
Пример #4
0
 def testUseCategoryIconEvenWhenCategorizableHasARecursiveIcon(self):
     child = categorizable.CategorizableCompositeObject(subject='child')
     self.categorizable.addChild(child)
     self.categorizable.setIcon('icon')
     self.category.setIcon('categoryIcon')
     child.addCategory(self.category)
     self.assertEqual('categoryIcon', child.icon(recursive=True))
Пример #5
0
 def testChildCategoryIncludedInParentDownwardRecursiveCategories(self):
     child = categorizable.CategorizableCompositeObject()
     child.addCategory(self.category)
     self.categorizable.addChild(child)
     self.assertEqual(
         set([self.category]),
         self.categorizable.categories(recursive=True, upwards=False))
Пример #6
0
 def testSubItemUsesParentFont(self):
     self.categorizable.addCategory(self.category)
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     self.category.setFont(wx.SWISS_FONT)
     self.assertEqual(wx.SWISS_FONT, child.font(recursive=True))
Пример #7
0
 def testSubItemUsesParentBackgroundColor(self):
     self.categorizable.addCategory(self.category)
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     self.category.setBackgroundColor(wx.RED)
     self.assertEqual(wx.RED, child.backgroundColor())
Пример #8
0
 def testRemoveCategoryCausesChildNotification(self):
     self.categorizable.addCategory(self.category)
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     self.registerObserver(self.categoryRemovedEventType, eventSource=child)
     self.categorizable.removeCategory(self.category)
     self.assertEvent(self.categoryRemovedEventType, child, self.category)
Пример #9
0
 def testSubItemUsesParentForegroundColor(self):
     self.categorizable.addCategory(self.category)
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     self.category.setForegroundColor(wx.RED)
     self.assertEqual(wx.RED, child.foregroundColor(recursive=True))
Пример #10
0
 def testAddParentToCategory(self):
     child = categorizable.CategorizableCompositeObject(subject='child')
     self.registerObserver(self.categoryAddedEventType, eventSource=child)
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     cat = category.Category(subject='Parent category')
     self.categorizable.addCategory(cat)
     self.assertEvent(self.categoryAddedEventType, child, cat)
Пример #11
0
 def testFontChanged_NotifySubItemsToo(self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     self.registerObserver(self.fontChangedEventType, eventSource=child)
     self.categorizable.addCategory(self.category)
     self.category.addCategorizable(self.categorizable)
     self.category.setFont(wx.SWISS_FONT)
     self.assertEqual(1, len(self.events))
Пример #12
0
 def testIconChanged_NotifySubItemsToo(self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     self.registerObserver(self.iconChangedEventType, eventSource=child)
     self.categorizable.addCategory(self.category)
     self.category.addCategorizable(self.categorizable)
     self.category.setIcon('icon')
     self.assertEqual(1, len(self.events))
Пример #13
0
 def testSubItemDoesNotUseParentBackgroundColorWhenItHasItsOwnBackgroundColor(
         self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     child.addCategory(self.category)
     self.categorizable.setBackgroundColor(wx.RED)
     self.category.setBackgroundColor(wx.BLUE)
     self.assertEqual(wx.BLUE, child.backgroundColor())
Пример #14
0
 def testBackgroundColorChanged_NotifySubItemsToo(self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     self.registerObserver(self.backgroundColorChangedEventType,
                           eventSource=child)
     self.categorizable.addCategory(self.category)
     self.category.addCategorizable(self.categorizable)
     self.category.setBackgroundColor(wx.RED)
     self.assertEqual(1, len(self.events))
Пример #15
0
 def testSubItemDoesNotUseParentForegroundColorWhenItHasItsOwnForegroundColor(
         self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     child.addCategory(self.category)
     self.categorizable.setForegroundColor(wx.RED)
     self.category.setForegroundColor(wx.BLUE)
     self.assertEqual(wx.BLUE, child.foregroundColor(recursive=True))
Пример #16
0
 def testCategorySubjectChanged_NotifySubItemsToo(self):
     childCategorizable = categorizable.CategorizableCompositeObject(
         subject='Child categorizable')
     self.registerObserver(self.categorySubjectChangedEventType,
                           eventSource=childCategorizable)
     self.categorizable.addChild(childCategorizable)
     self.categorizable.addCategory(self.category)
     self.category.addCategorizable(self.categorizable)
     self.category.setSubject('New subject')
     self.assertEvent(self.categorySubjectChangedEventType,
                      childCategorizable, 'New subject')
Пример #17
0
 def testToggleCategory_WhenSomeCategorizablesAreInCategory(self):
     ''' If some of the selected categorizables are in the category and some
         are not, toggle category puts all categorizables in the category, 
         rather than toggling all categorizables. '''
     categorizable2 = categorizable.CategorizableCompositeObject(
         subject='Categorizable2')
     categorizable2.addCategory(self.category)
     self.category.addCategorizable(categorizable2)
     self.toggleItem([self.categorizable, categorizable2])
     self.assertDoUndoRedo(\
         lambda: self.assertEqual(set([self.categorizable, categorizable2]), self.category.categorizables()),
         lambda: self.assertEqual(set([categorizable2]), self.category.categorizables()))
Пример #18
0
 def testSubItemDoesNotUseParentFontWhenItHasItsOwnFont(self):
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     child.setParent(self.categorizable)
     child.addCategory(self.category)
     self.categorizable.setFont(
         wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                 wx.FONTWEIGHT_NORMAL))
     categoryFont = wx.Font(11, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_NORMAL)
     self.category.setFont(categoryFont)
     self.assertEqual(categoryFont, child.font(recursive=True))
Пример #19
0
 def setUp(self):
     super(ToggleCategoryCommandTestCase, self).setUp()
     self.category = category.Category('Cat')
     self.categorizable = categorizable.CategorizableCompositeObject(
         subject='Categorizable')
Пример #20
0
 def testAddCategoriesViaConstructor(self):
     anotherCategory = category.Category('Another category')
     categories = [self.category, anotherCategory]
     categorizableObject = categorizable.CategorizableCompositeObject(categories= \
         categories)
     self.assertEqual(set(categories), categorizableObject.categories())
Пример #21
0
 def testAddCategoryViaConstructor(self):
     categorizableObject = categorizable.CategorizableCompositeObject(
         categories=[self.category])
     self.assertEqual(set([self.category]),
                      categorizableObject.categories())
Пример #22
0
 def setUp(self):
     self.categorizable = categorizable.CategorizableCompositeObject(
         subject='categorizable')
     self.category = category.Category('category')
Пример #23
0
 def testChildCategoriesNotIncludedInNonRecursiveCategories(self):
     child = categorizable.CategorizableCompositeObject()
     child.addCategory(self.category)
     self.categorizable.addChild(child)
     self.assertEqual(set(), self.categorizable.categories(recursive=False))
Пример #24
0
 def testParentCategoryIncludedInChildUpwardRecursiveCategories(self):
     self.categorizable.addCategory(self.category)
     child = categorizable.CategorizableCompositeObject()
     self.categorizable.addChild(child)
     self.assertEqual(set([self.category]),
                      child.categories(recursive=True, upwards=True))