Exemplo n.º 1
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))
        )
Exemplo n.º 2
0
    def testAddCover_01_group(self):
        files = []
        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)))

        collection.setCover(groupname, coverpath)
        self.assertTrue(
            os.path.exists(
                os.path.join(self.tempDir1, groupname,
                             IconsCollection.COVER_FILE_NAME)))
Exemplo n.º 3
0
    def testRemoveGroup_02(self):
        os.mkdir(self.tempDir1)

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

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

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

        collection.removeGroup('Новая группа')
        self.assertEqual(collection.getGroups(), [])
Exemplo n.º 5
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'Абырвалг')
Exemplo n.º 6
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'')
Exemplo n.º 7
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('Новая группа'), [])
Exemplo n.º 8
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'Новая группа'), [])
Exemplo n.º 9
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'Новая группа'])
Exemplo n.º 10
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(), ['Новая группа'])
Exemplo n.º 11
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(), ['Новая группа'])
Exemplo n.º 12
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'Новая группа'])
Exemplo n.º 13
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(), [])
Exemplo n.º 14
0
    def testRenameGroup_04_invalid(self):
        os.mkdir(self.tempDir1)

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

        self.assertRaises(
            DuplicateGroupError,
            collection.renameGroup,
            'Новая группа',
            'Абырвалг')
Exemplo n.º 15
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'Новая группа'])
Exemplo n.º 16
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'Другая группа'])
Exemplo n.º 17
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'Переименованная группа'])
Exemplo 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(), ['Другая группа'])
Exemplo n.º 19
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(), [])
Exemplo n.º 20
0
    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(),
                         ['Переименованная группа'])
Exemplo n.º 21
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)
Exemplo n.º 22
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)
Exemplo 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'Абырвалг\\Абырвалг')
Exemplo n.º 24
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(),
                         ['Вторая группа', 'Новая группа'])
Exemplo n.º 25
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,
            '')
Exemplo n.º 26
0
    def testAddIcons_10_not_exists(self):
        files = [u'new.png', u'image_01.JPG', u'notexists.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'image_01.png', icons[0])
        self.assertIn(u'new.png', icons[1])
Exemplo n.º 27
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)
Exemplo n.º 28
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])
Exemplo n.º 29
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])
Exemplo n.º 30
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])
Exemplo n.º 31
0
    def testAddIcons_10_not_exists(self):
        files = ['new.png', 'image_01.JPG', 'notexists.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('image_01.png', icons[0])
        self.assertIn('new.png', icons[1])
Exemplo n.º 32
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])
Exemplo n.º 33
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)
Exemplo n.º 34
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,
            'Новая группа',
            'Абырвалг\\Абырвалг')