def testRenameGroup_03_self(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup(u'Новая группа') collection.renameGroup(u'Новая группа', u'Новая группа') self.assertEqual(collection.getGroups(), [u'Новая группа']) newcollection = IconsCollection(self.tempDir1) self.assertEqual(newcollection.getGroups(), [u'Новая группа'])
def testRenameGroup_03_self(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup('Новая группа') collection.renameGroup('Новая группа', 'Новая группа') self.assertEqual(collection.getGroups(), ['Новая группа']) newcollection = IconsCollection(self.tempDir1) self.assertEqual(newcollection.getGroups(), ['Новая группа'])
def testAddGroup_01(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) self.assertEqual(collection.getGroups(), []) collection.addGroup(u'Новая группа') self.assertEqual(collection.getGroups(), [u'Новая группа']) newcollection1 = IconsCollection(self.tempDir1) self.assertEqual(newcollection1.getGroups(), [u'Новая группа'])
def testAddGroup_01(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) self.assertEqual(collection.getGroups(), []) collection.addGroup('Новая группа') self.assertEqual(collection.getGroups(), ['Новая группа']) newcollection1 = IconsCollection(self.tempDir1) self.assertEqual(newcollection1.getGroups(), ['Новая группа'])
def testRenameGroup_01 (self): os.mkdir (self.tempDir1) collection = IconsCollection (self.tempDir1) collection.addGroup (u'Новая группа') self.assertEqual (collection.getGroups(), [u'Новая группа']) collection.renameGroup (u'Новая группа', u'Переименованная группа') self.assertEqual (collection.getGroups(), [u'Переименованная группа']) newcollection1 = IconsCollection (self.tempDir1) self.assertEqual (newcollection1.getGroups(), [u'Переименованная группа'])
def testRemoveGroup_01(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup('Новая группа') collection.addGroup('Другая группа') collection.removeGroup('Новая группа') self.assertEqual(collection.getGroups(), ['Другая группа']) newcollection1 = IconsCollection(self.tempDir1) self.assertEqual(newcollection1.getGroups(), ['Другая группа'])
def testAddGroup_03 (self): os.mkdir (self.tempDir1) collection = IconsCollection (self.tempDir1) self.assertEqual (collection.getGroups(), []) collection.addGroup (u'Новая группа') collection.addGroup (u'Вторая группа') self.assertEqual (collection.getGroups(), [u'Вторая группа', u'Новая группа']) newcollection = IconsCollection (self.tempDir1) self.assertEqual (newcollection.getGroups(), [u'Вторая группа', u'Новая группа'])
def testRemoveGroup_01 (self): os.mkdir (self.tempDir1) collection = IconsCollection (self.tempDir1) collection.addGroup (u'Новая группа') collection.addGroup (u'Другая группа') collection.removeGroup (u'Новая группа') self.assertEqual (collection.getGroups(), [u'Другая группа']) newcollection1 = IconsCollection (self.tempDir1) self.assertEqual (newcollection1.getGroups(), [u'Другая группа'])
def testRenameGroup_01(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup('Новая группа') self.assertEqual(collection.getGroups(), ['Новая группа']) collection.renameGroup('Новая группа', 'Переименованная группа') self.assertEqual(collection.getGroups(), ['Переименованная группа']) newcollection1 = IconsCollection(self.tempDir1) self.assertEqual(newcollection1.getGroups(), ['Переименованная группа'])
def testAddGroup_03(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) self.assertEqual(collection.getGroups(), []) collection.addGroup('Новая группа') collection.addGroup('Вторая группа') self.assertEqual(collection.getGroups(), ['Вторая группа', 'Новая группа']) newcollection = IconsCollection(self.tempDir1) self.assertEqual(newcollection.getGroups(), ['Вторая группа', 'Новая группа'])
def testRenameGroup_04_self(self): files = ['new.png', 'image_01.JPG'] fullPaths = [os.path.join(self.imagesDir, fname) for fname in files] os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup('Новая группа') collection.addIcons('Новая группа', fullPaths) collection.renameGroup('Новая группа', 'Новая группа') self.assertEqual(collection.getGroups(), ['Новая группа']) self.assertEqual(len(collection.getIcons('Новая группа')), 2) newcollection = IconsCollection(self.tempDir1) self.assertEqual(newcollection.getGroups(), ['Новая группа']) self.assertEqual(len(newcollection.getIcons('Новая группа')), 2)
def _getGroupsInfo(self): result = [] for n, path in enumerate(getIconsDirList()): # First None is root directory collection = IconsCollection(path) for groupname in [None] + sorted(collection.getGroups(), key=self._localize): # Get group name if groupname is None: title = _(u'Not in groups') else: title = self._localize(groupname) iconslist = collection.getIcons(groupname) cover = collection.getCover(groupname) if cover is None: cover = self._default_group_cover group_type = (IconsGroupInfo.TYPE_BUILTIN if n == 0 else IconsGroupInfo.TYPE_CUSTOM) result.append(IconsGroupInfo(iconslist, title, cover, group_type=group_type, sort_key=os.path.basename)) self._addRecentIconsGroup(result) eventParam = IconsGroupsListInitParams(result) self._application.onIconsGroupsListInit(self._page, eventParam) return eventParam.groupsList
def _getGroupsInfo(self): result = [] for n, path in enumerate(getIconsDirList()): # First None is root directory collection = IconsCollection(path) for groupname in [None] + sorted(collection.getGroups(), key=self._localize): # Get group name if groupname is None: title = _(u'Not in groups') else: title = self._localize(groupname) iconslist = collection.getIcons(groupname) cover = collection.getCover(groupname) if cover is None: cover = self._default_group_cover group_type = (IconsGroupInfo.TYPE_BUILTIN if n == 0 else IconsGroupInfo.TYPE_CUSTOM) result.append(IconsGroupInfo(iconslist, title, cover, group_type=group_type, sort_key=os.path.basename)) self._addRecentIconsGroup(result) eventParam = IconsGroupsListInitParams(result) self._application.onIconsGroupsListInit(self._page, eventParam) return eventParam.groupsList
def testRenameGroup_04_self(self): files = [u'new.png', u'image_01.JPG'] fullPaths = [os.path.join(self.imagesDir, fname) for fname in files] os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup(u'Новая группа') collection.addIcons(u'Новая группа', fullPaths) collection.renameGroup(u'Новая группа', u'Новая группа') self.assertEqual(collection.getGroups(), [u'Новая группа']) self.assertEqual(len(collection.getIcons(u'Новая группа')), 2) newcollection = IconsCollection(self.tempDir1) self.assertEqual(newcollection.getGroups(), [u'Новая группа']) self.assertEqual(len(newcollection.getIcons(u'Новая группа')), 2)
def _getGroupsInfo(self): result = [] for n, path in enumerate(getIconsDirList()): # First None is root directory collection = IconsCollection(path) for groupname in [None] + sorted(collection.getGroups(), key=self._localize): # Get group name if groupname is None: title = _(u'Not in groups') else: title = self._localize(groupname) if n != 0: title += u' *' iconslist = collection.getIcons(groupname) cover = collection.getCover(groupname) result.append(IconsGroupInfo(iconslist, title, cover, sort_key=os.path.basename)) self._addRecentIconsGroup(result) return result
def testGroups_02(self): collection = IconsCollection(u'../test/icons/Только группы') self.assertEqual(len(collection.getIcons(None)), 0) self.assertEqual(collection.getGroups(), [u'Группа 3', u'Группа 4']) self.assertEqual(len(collection.getIcons(u'Группа 3')), 3) self.assertEqual(len(collection.getIcons(u'Группа 4')), 4) self.assertIsNone(collection.getCover(None))
def testEmpty_02(self): collection = IconsCollection(u'../test/icons/Без иконок') self.assertEqual(collection.getIcons(None), []) self.assertEqual(collection.getGroups(), []) self.assertRaises(KeyError, collection.getIcons, u'Группа') self.assertRaises(KeyError, collection.getCover, u'Группа') self.assertIsNone(collection.getCover(u''))
def testRemoveGroup_02(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup(u'Новая группа') collection.removeGroup(u'Новая группа') self.assertEqual(collection.getGroups(), [])
def testRemoveGroup_02(self): os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup('Новая группа') collection.removeGroup('Новая группа') self.assertEqual(collection.getGroups(), [])
def testEmpty_02(self): collection = IconsCollection('../test/icons/Без иконок') self.assertEqual(collection.getIcons(None), []) self.assertEqual(collection.getGroups(), []) self.assertRaises(KeyError, collection.getIcons, 'Группа') self.assertRaises(KeyError, collection.getCover, 'Группа') self.assertIsNone(collection.getCover(''))
def testEmpty_01(self): collection = IconsCollection('testdata/icons/Без иконок') self.assertEqual(collection.getIcons(''), []) self.assertEqual(collection.getGroups(), []) self.assertRaises(KeyError, collection.getIcons, 'Группа') self.assertRaises(KeyError, collection.getCover, 'Группа') self.assertIsNone(collection.getCover(None))
def testGroups_02(self): collection = IconsCollection('../test/icons/Только группы') self.assertEqual(len(collection.getIcons(None)), 0) self.assertEqual(collection.getGroups(), ['Группа 3', 'Группа 4']) self.assertEqual(len(collection.getIcons('Группа 3')), 3) self.assertEqual(len(collection.getIcons('Группа 4')), 4) self.assertIsNone(collection.getCover(None))
def testGroups_01 (self): collection = IconsCollection (u'../test/icons/Иконки и группы') self.assertEqual (len (collection.getIcons(None)), 4) self.assertEqual (collection.getGroups(), [u'Группа 1', u'Группа 2']) self.assertEqual (len (collection.getIcons (u'Группа 1')), 3) self.assertEqual (len (collection.getIcons (u'Группа 2')), 4) self.assertIsNone (collection.getCover(None)) self.assertTrue (collection.getCover(u'Группа 1').endswith (u'__cover.png')) self.assertIsNone (collection.getCover(u'Группа 2'))
def testGroups_01(self): collection = IconsCollection(u'../test/icons/Иконки и группы') self.assertEqual(len(collection.getIcons(None)), 4) self.assertEqual(collection.getGroups(), [u'Группа 1', u'Группа 2']) self.assertEqual(len(collection.getIcons(u'Группа 1')), 3) self.assertEqual(len(collection.getIcons(u'Группа 2')), 4) self.assertIsNone(collection.getCover(None)) self.assertTrue( collection.getCover(u'Группа 1').endswith(u'__cover.png')) self.assertIsNone(collection.getCover(u'Группа 2'))
def testRemoveGroup_04 (self): files = [u'new.png', u'image_01.JPG'] fullPaths = [os.path.join (self.imagesDir, fname) for fname in files] os.mkdir (self.tempDir1) collection = IconsCollection (self.tempDir1) collection.addGroup (u'Новая группа') collection.addIcons (u'Новая группа', fullPaths) collection.removeGroup (u'Новая группа') self.assertEqual (collection.getGroups(), [])
def testRemoveGroup_04(self): files = ['new.png', 'image_01.JPG'] fullPaths = [os.path.join(self.imagesDir, fname) for fname in files] os.mkdir(self.tempDir1) collection = IconsCollection(self.tempDir1) collection.addGroup('Новая группа') collection.addIcons('Новая группа', fullPaths) collection.removeGroup('Новая группа') self.assertEqual(collection.getGroups(), [])
def testSingleRoot(self): collection = IconsCollection(u'../test/icons/Без групп') self.assertEqual(len(collection.getIcons(None)), 4) self.assertEqual(collection.getGroups(), []) self.assertTrue(collection.getCover(None).endswith(u'__cover.png'))
def testSingleRoot(self): collection = IconsCollection('../test/icons/Без групп') self.assertEqual(len(collection.getIcons(None)), 4) self.assertEqual(collection.getGroups(), []) self.assertTrue(collection.getCover(None).endswith('__cover.png'))