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 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))
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))
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))
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))
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))
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())
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)
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))
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)
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))
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))
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())
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))
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))
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')
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()))
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))
def setUp(self): super(ToggleCategoryCommandTestCase, self).setUp() self.category = category.Category('Cat') self.categorizable = categorizable.CategorizableCompositeObject( subject='Categorizable')
def testAddCategoriesViaConstructor(self): anotherCategory = category.Category('Another category') categories = [self.category, anotherCategory] categorizableObject = categorizable.CategorizableCompositeObject(categories= \ categories) self.assertEqual(set(categories), categorizableObject.categories())
def testAddCategoryViaConstructor(self): categorizableObject = categorizable.CategorizableCompositeObject( categories=[self.category]) self.assertEqual(set([self.category]), categorizableObject.categories())
def setUp(self): self.categorizable = categorizable.CategorizableCompositeObject( subject='categorizable') self.category = category.Category('category')
def testChildCategoriesNotIncludedInNonRecursiveCategories(self): child = categorizable.CategorizableCompositeObject() child.addCategory(self.category) self.categorizable.addChild(child) self.assertEqual(set(), self.categorizable.categories(recursive=False))
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))