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'Новая группа'])
Example #2
0
    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'Новая группа'])
Example #4
0
    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(), ['Новая группа'])
Example #5
0
    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(), ['Другая группа'])
Example #7
0
    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'Новая группа'])
Example #8
0
    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(),
                         ['Переименованная группа'])
Example #10
0
    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(),
                         ['Вторая группа', 'Новая группа'])
Example #11
0
    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)
Example #12
0
    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
Example #13
0
    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
Example #14
0
    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)
Example #15
0
    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
Example #16
0
    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))
Example #17
0
    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''))
Example #18
0
    def testRemoveGroup_02(self):
        os.mkdir(self.tempDir1)

        collection = IconsCollection(self.tempDir1)
        collection.addGroup(u'Новая группа')

        collection.removeGroup(u'Новая группа')
        self.assertEqual(collection.getGroups(), [])
Example #19
0
    def testRemoveGroup_02(self):
        os.mkdir(self.tempDir1)

        collection = IconsCollection(self.tempDir1)
        collection.addGroup('Новая группа')

        collection.removeGroup('Новая группа')
        self.assertEqual(collection.getGroups(), [])
Example #20
0
    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(''))
Example #21
0
    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))
Example #22
0
    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))
Example #23
0
    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'))
Example #24
0
    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'))
Example #25
0
    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(), [])
Example #26
0
    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(), [])
Example #27
0
    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'))
Example #28
0
    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'))