Esempio n. 1
0
    def test_create(self):
        path = os.path.join(self.testDataPath, 'collection_1')
        abspath = os.path.abspath(path)

        folder = Folder(path)
        self.assertEqual(abspath, folder.getPath())

        # We have:
        # collection_1
        #   A
        #   B
        #      a
        #      b
        #   C
        #      a
        #      b
        #         i
        #         ii
        #      c

        subfolders = folder.getSubFolders()
        self.assertEqual(3, len(subfolders))

        folderA = subfolders[0]
        self.assertEqual(os.path.join(abspath, 'A'), folderA.getPath())
        self.assertEqual(0, len(folderA.getSubFolders()))

        folderB = subfolders[1]
        self.assertEqual(os.path.join(abspath, 'B'), folderB.getPath())
        self.assertEqual(2, len(folderB.getSubFolders()))

        folderC = subfolders[2]
        self.assertEqual(os.path.join(abspath, 'C'), folderC.getPath())
        self.assertEqual(3, len(folderC.getSubFolders()))

        folderBa = folderB.getSubFolders()[0]
        self.assertEqual(os.path.join(abspath, 'B', 'a'), folderBa.getPath())
        self.assertEqual(0, len(folderBa.getSubFolders()))

        folderBb = folderB.getSubFolders()[1]
        self.assertEqual(os.path.join(abspath, 'B', 'b'), folderBb.getPath())
        self.assertEqual(0, len(folderBb.getSubFolders()))

        folderCb = folderC.getSubFolders()[1]
        self.assertEqual(os.path.join(abspath, 'C', 'b'), folderCb.getPath())
        self.assertEqual(2  , len(folderCb.getSubFolders()))
Esempio n. 2
0
    def test_createWithIllegalPath(self):
        folder = Folder(None)
        self.assertEquals(None, folder.getPath())
        self.assertFalse(folder.exists())
        self.assertEquals([], folder.getSubFolders())

        folder = Folder(1)
        self.assertEquals(None, folder.getPath())
        self.assertFalse(folder.exists())
        self.assertEquals([], folder.getSubFolders())

        folder = Folder([])
        self.assertEquals(None, folder.getPath())
        self.assertFalse(folder.exists())
        self.assertEquals([], folder.getSubFolders())

        folder = Folder("Hello World!");
        self.assertEquals(None, folder.getPath())
        self.assertFalse(folder.exists())
        self.assertEquals([], folder.getSubFolders())