Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
    def testAddCover_01_group(self):
        files = []
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = 'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)
        collection.addIcons(groupname, fullPaths)

        coverpath = os.path.join(self.imagesDir, 'icon.png')

        newCoverPath = os.path.join(self.tempDir1,
                                    groupname,
                                    IconsCollection.COVER_FILE_NAME)

        collection.setCover(groupname, coverpath)
        self.assertTrue(os.path.exists(newCoverPath))
        self.assertEqual(os.path.abspath(newCoverPath),
                         os.path.abspath(collection.getCover(groupname)))

        collection.setCover(groupname, coverpath)
        self.assertTrue(os.path.exists(os.path.join(
            self.tempDir1,
            groupname,
            IconsCollection.COVER_FILE_NAME))
        )
Ejemplo n.º 4
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
Ejemplo n.º 5
0
    def testAddIcons_19_resize(self):
        files = ['16x16.png',
                 '16x15.png',
                 '16x17.png',
                 '15x16.png',
                 '17x16.png',
                 '17x17.png',
                 '15x15.png',
                 '8x8.png',
                 '8x16.png',
                 '16x8.png',
                 'first.png',
                 'first_vertical.png']

        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addIcons(None, fullPaths)

        icons = sorted(collection.getIcons(None))
        self.assertEqual(len(icons), 12)

        icons = {fname: os.path.join(self.tempDir1, fname) for fname in files}

        for fname in files:
            self.assertEqual(getImageSize(icons[fname]), (16, 16))
Ejemplo n.º 6
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))
Ejemplo n.º 7
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''))
Ejemplo n.º 8
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))
Ejemplo n.º 9
0
    def testAddCover_04_root_invalid (self):
        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)

        coverpath = os.path.join (self.imagesDir, u'invalid.png')

        collection.setCover (u'', coverpath)
        self.assertFalse (os.path.exists (os.path.join (self.tempDir1, IconsCollection.COVER_FILE_NAME)))
Ejemplo n.º 10
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(''))
Ejemplo n.º 11
0
    def testAddIcons_03_empty(self):
        files = []
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        collection.addIcons('', fullPaths)
        self.assertEqual(collection.getIcons(None), [])
Ejemplo n.º 12
0
    def testRemoveGroup_03_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(KeyError, collection.removeGroup, u'Абырвалг')

        self.assertRaises(KeyError, collection.removeGroup, u'')
Ejemplo n.º 13
0
    def testAddIcons_03_empty(self):
        files = []
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        collection.addIcons(u'', fullPaths)
        self.assertEqual(collection.getIcons(None), [])
Ejemplo n.º 14
0
    def testAddCover_04_root_invalid(self):
        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        coverpath = os.path.join(self.imagesDir, u'invalid.png')

        collection.setCover(u'', coverpath)
        self.assertFalse(
            os.path.exists(
                os.path.join(self.tempDir1, IconsCollection.COVER_FILE_NAME)))
Ejemplo n.º 15
0
    def testAddIcons_06(self):
        files = ['new.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        collection.addIcons(None, fullPaths)

        icons = collection.getIcons(None)
        self.assertIn('new.png', icons[0])
Ejemplo n.º 16
0
    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'Новая группа'])
Ejemplo n.º 17
0
    def testAddIcons_06(self):
        files = [u'new.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        collection.addIcons(None, fullPaths)

        icons = collection.getIcons(None)
        self.assertIn(u'new.png', icons[0])
Ejemplo n.º 18
0
    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(), ['Другая группа'])
Ejemplo n.º 19
0
    def testAddIcons_07 (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.addIcons (None, fullPaths)

        icons = sorted (collection.getIcons (None))
        self.assertIn (u'image_01.png', icons[0])
        self.assertIn (u'new.png', icons[1])
Ejemplo n.º 20
0
    def testAddCover_05_root (self):
        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)

        coverpath = os.path.join (self.imagesDir, u'first.jpg')

        collection.setCover (None, coverpath)
        self.assertTrue (os.path.exists (os.path.join (self.tempDir1, IconsCollection.COVER_FILE_NAME)))

        self.assertEqual (self.__getMaxImageSize (os.path.join (
            self.tempDir1,
            IconsCollection.COVER_FILE_NAME)), 16)
Ejemplo n.º 21
0
    def testRenameGroup_04_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(
            DuplicateGroupError,
            collection.renameGroup,
            'Новая группа',
            'Абырвалг')
Ejemplo n.º 22
0
    def testAddIcons_07(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.addIcons(None, fullPaths)

        icons = sorted(collection.getIcons(None))
        self.assertIn('image_01.png', icons[0])
        self.assertIn('new.png', icons[1])
Ejemplo n.º 23
0
    def testRenameGroup_02_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(ValueError, collection.renameGroup, u'Новая группа',
                          u'')

        self.assertRaises(ValueError, collection.renameGroup, u'Новая группа',
                          u'Абырвалг/Абырвалг')

        self.assertRaises(ValueError, collection.renameGroup, u'Новая группа',
                          u'Абырвалг\\Абырвалг')
Ejemplo n.º 24
0
    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'Новая группа'])
Ejemplo n.º 25
0
    def testAddCover_05_root(self):
        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        coverpath = os.path.join(self.imagesDir, u'first.jpg')

        collection.setCover(None, coverpath)
        self.assertTrue(
            os.path.exists(
                os.path.join(self.tempDir1, IconsCollection.COVER_FILE_NAME)))

        self.assertEqual(
            self.__getMaxImageSize(
                os.path.join(self.tempDir1, IconsCollection.COVER_FILE_NAME)),
            16)
Ejemplo n.º 26
0
    def testRemoveGroup_03_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(
            KeyError,
            collection.removeGroup,
            'Абырвалг')

        self.assertRaises(
            KeyError,
            collection.removeGroup,
            '')
Ejemplo n.º 27
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'Новая группа'])
Ejemplo n.º 28
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'Переименованная группа'])
Ejemplo n.º 29
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(), [])
Ejemplo n.º 30
0
    def testAddGroup_02_invalid(self):
        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        self.assertRaises(ValueError, collection.addGroup,
                          'Абырвалг\\Абырвалг')
        self.assertRaises(ValueError, collection.addGroup, 'Абырвалг/Абырвалг')
        self.assertRaises(ValueError, collection.addGroup, '')
Ejemplo n.º 31
0
    def testAddIcons_04_invalid(self):
        files = [u'new.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        self.assertRaises(KeyError, collection.addIcons, u'Другая группа',
                          fullPaths)
Ejemplo n.º 32
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(), ['Новая группа'])
Ejemplo n.º 33
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'))
Ejemplo n.º 34
0
    def testRemoveGroup_02(self):
        os.mkdir(self.tempDir1)

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

        collection.removeGroup(u'Новая группа')
        self.assertEqual(collection.getGroups(), [])
Ejemplo n.º 35
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(), [])
Ejemplo n.º 36
0
    def __init__(self, parent):
        super(IconsPanel, self).__init__(parent)

        self._iconsCollections = [
            IconsCollection(path) for path in getIconsDirList()
        ]
        self.__createGui()

        self.__appendGroups()
        self.groupCtrl.SetSelection(0)
        self.__switchToCurrentGroup()
Ejemplo n.º 37
0
    def testAddIcons_19_resize(self):
        files = [
            u'16x16.png', u'16x15.png', u'16x17.png', u'15x16.png',
            u'17x16.png', u'17x17.png', u'15x15.png', u'8x8.png', u'8x16.png',
            u'16x8.png', u'first.png', u'first_vertical.png'
        ]

        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addIcons(None, fullPaths)

        icons = sorted(collection.getIcons(None))
        self.assertEqual(len(icons), 12)

        icons = {fname: os.path.join(self.tempDir1, fname) for fname in files}

        for fname in files:
            self.assertEqual(getImageSize(icons[fname]), (16, 16))
Ejemplo n.º 38
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'))
Ejemplo n.º 39
0
    def testAddIcons_02_empty(self):
        files = []
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

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

        collection.addIcons('Новая группа', fullPaths)
        self.assertEqual(collection.getIcons('Новая группа'), [])
Ejemplo n.º 40
0
    def testRemoveGroup_02(self):
        os.mkdir(self.tempDir1)

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

        collection.removeGroup('Новая группа')
        self.assertEqual(collection.getGroups(), [])
Ejemplo n.º 41
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))
Ejemplo n.º 42
0
    def testRenameGroup_02_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(
            ValueError,
            collection.renameGroup,
            'Новая группа',
            '')

        self.assertRaises(
            ValueError,
            collection.renameGroup,
            'Новая группа',
            'Абырвалг/Абырвалг')

        self.assertRaises(
            ValueError,
            collection.renameGroup,
            'Новая группа',
            'Абырвалг\\Абырвалг')
Ejemplo n.º 43
0
    def testRenameGroup_04_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(DuplicateGroupError, collection.renameGroup,
                          u'Новая группа', u'Абырвалг')
Ejemplo n.º 44
0
    def testAddCover_06_group(self):
        files = [u'new.png', '8x8.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = u'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)
        collection.addIcons(groupname, fullPaths)

        coverpath = os.path.join(self.imagesDir, u'icon.png')

        newCoverPath = os.path.join(self.tempDir1, groupname,
                                    IconsCollection.COVER_FILE_NAME)

        collection.setCover(groupname, coverpath)
        self.assertTrue(os.path.exists(newCoverPath))
        self.assertEqual(os.path.abspath(newCoverPath),
                         os.path.abspath(collection.getCover(groupname)))
Ejemplo n.º 45
0
    def testAddIcons_08(self):
        files = [u'new.png', u'image_01.JPG']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = u'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 2)
        self.assertIn(u'image_01.png', icons[0])
        self.assertIn(u'new.png', icons[1])
        self.assertIsNone(collection.getCover(u'Новая группа'))
Ejemplo n.º 46
0
    def testAddIcons_02_empty (self):
        files = []
        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)
        self.assertEqual (collection.getIcons (u'Новая группа'), [])
Ejemplo n.º 47
0
    def testAddIcons_16_invalid(self):
        files = [u'invalid.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = u'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 0)
Ejemplo n.º 48
0
    def testAddIcons_11(self):
        files = ['new.png', 'new.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = 'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 2)
        self.assertIn('new.png', icons[0])
        self.assertIn('new_(1).png', icons[1])
Ejemplo n.º 49
0
    def testAddIcons_13(self):
        files = [u'__sample.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = u'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 1)
        self.assertNotIn(u'__sample.png', icons[0])
        self.assertIn(u'sample.png', icons[0])
Ejemplo n.º 50
0
    def testAddIcons_08(self):
        files = ['new.png', 'image_01.JPG']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = 'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 2)
        self.assertIn('image_01.png', icons[0])
        self.assertIn('new.png', icons[1])
        self.assertIsNone(collection.getCover('Новая группа'))
Ejemplo n.º 51
0
    def testAddIcons_16_invalid(self):
        files = ['invalid.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = 'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 0)
Ejemplo n.º 52
0
    def testAddCover_03_root (self):
        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)

        coverpath = os.path.join (self.imagesDir, u'icon.png')

        newCoverPath = os.path.join (self.tempDir1, IconsCollection.COVER_FILE_NAME)

        collection.setCover (u'', coverpath)
        self.assertTrue (os.path.exists (newCoverPath))
        self.assertEqual (os.path.abspath (newCoverPath), os.path.abspath (collection.getCover (None)))

        collection.setCover (u'', coverpath)
        self.assertTrue (os.path.exists (os.path.join (self.tempDir1, IconsCollection.COVER_FILE_NAME)))
Ejemplo n.º 53
0
    def testAddCover_03_root(self):
        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        coverpath = os.path.join(self.imagesDir, u'icon.png')

        newCoverPath = os.path.join(self.tempDir1,
                                    IconsCollection.COVER_FILE_NAME)

        collection.setCover(u'', coverpath)
        self.assertTrue(os.path.exists(newCoverPath))
        self.assertEqual(os.path.abspath(newCoverPath),
                         os.path.abspath(collection.getCover(None)))

        collection.setCover(u'', coverpath)
        self.assertTrue(
            os.path.exists(
                os.path.join(self.tempDir1, IconsCollection.COVER_FILE_NAME)))
Ejemplo n.º 54
0
    def testAddIcons_11 (self):
        files = [u'new.png', u'new.png']
        fullPaths = [os.path.join (self.imagesDir, fname) for fname in files]

        groupname = u'Новая группа'

        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)
        collection.addGroup (groupname)

        collection.addIcons (groupname, fullPaths)

        icons = sorted (collection.getIcons (groupname))
        self.assertEqual (len (icons), 2)
        self.assertIn (u'new.png', icons[0])
        self.assertIn (u'new_(1).png', icons[1])
Ejemplo n.º 55
0
    def testAddIcons_13(self):
        files = ['__sample.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = 'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)

        collection.addIcons(groupname, fullPaths)

        icons = sorted(collection.getIcons(groupname))
        self.assertEqual(len(icons), 1)
        self.assertNotIn('__sample.png', icons[0])
        self.assertIn('sample.png', icons[0])
Ejemplo n.º 56
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)
Ejemplo n.º 57
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'))
Ejemplo n.º 58
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'))