def testCreateFolder(self):
		deleteTree(testPath)
		baseFolder = OutContextFolder(modulePath)
		filesFolder = baseFolder.createFolder('files')
		subFolder = filesFolder.createFolder('subFolder')
		self.assertTrue(os.path.isdir(testPath))
		self.assertTrue(os.path.isdir(os.path.join(testPath, 'subFolder')))
Exemplo n.º 2
0
    def testCreateTree(self):
        """Тест создания иерархии пакетов"""
        path0 = os.path.split(__file__)[0]
        path0 = os.path.join(path0, 'files')
        pathDst = os.path.join(path0, 'dst')
        deleteTree(pathDst)

        def createPackage(name, items=[]):
            package = PyPackage()
            package.name = name
            [package.addNamedItem(i) for i in items]
            return package

        part11 = createPackage('part11')
        part1 = createPackage('part1', [part11])
        part2 = createPackage('part2')
        dst = createPackage('dst', [part1, part2])
        self.assertIn('part1', dst.dictionary)

        outContext = OutContextFolder(path0)
        self.assertFalse(os.path.isdir(pathDst))
        dst.export(outContext)
        self.assertTrue(os.path.isdir(pathDst))
        self.assertTrue(os.path.isfile(os.path.join(pathDst, iniName)))
        self.assertTrue(os.path.isdir(os.path.join(pathDst, 'part1')))
        self.assertTrue(os.path.isfile(os.path.join(pathDst, 'part1',
                                                    iniName)))
        self.assertTrue(os.path.isdir(os.path.join(pathDst, 'part1',
                                                   'part11')))
        self.assertTrue(
            os.path.isfile(os.path.join(pathDst, 'part1', 'part11', iniName)))
Exemplo n.º 3
0
def exportProject(srcRoot, dirName, core):
    outPath = os.path.join(rootPath, dirName)
    print('Export to ' + outPath)
    dstRoot = srcRoot.cloneRoot(core)
    deleteTree(outPath)
    os.mkdir(outPath)
    outContext = OutContextFolder(outPath)
    dstRoot.export(outContext)
Exemplo n.º 4
0
	def testExport(self):
		root = WppPackage('packageTest')
		root.read(os.path.join(os.path.dirname(__file__), root.name))
		root.fullUpdate()

		exportRoot = os.path.join(os.path.dirname(__file__), 'exportTest')
		deleteTree(exportRoot)
		os.mkdir(exportRoot)

		outContext = OutContextFolder(exportRoot)
		root.export(outContext)
		folder1 = os.path.join(exportRoot, root.name, 'folder1')
		folder11 = os.path.join(folder1, 'folder11')
		self.assertTrue(os.path.isdir(folder1))
		self.assertTrue(os.path.isdir(folder11))
		folder22 = os.path.join(exportRoot, root.name, 'folder2', 'folder22')
		self.assertTrue(os.path.isdir(folder22))
Exemplo n.º 5
0
    def testCopyTree(self):
        """ Тест копирования иерархии """
        path0 = os.path.split(__file__)[0]
        path0 = os.path.join(path0, 'files')
        pathDst = os.path.join(path0, 'dst1')
        deleteTree(pathDst)
        self.assertFalse(os.path.isdir(pathDst))

        # Создать исходную иерархию
        pathSrc = os.path.join(path0, 'src1')
        if not os.path.exists(pathSrc):
            os.mkdir(pathSrc)
            os.mkdir(os.path.join(pathSrc, 'packageA'))
            os.mkdir(os.path.join(pathSrc, 'packageA', 'packageA1'))
            os.mkdir(os.path.join(pathSrc, 'packageA', 'packageA2'))
            os.mkdir(os.path.join(pathSrc, 'packageB'))
            os.mkdir(os.path.join(pathSrc, 'packageB', 'packageB1'))
            os.mkdir(os.path.join(pathSrc, 'packageB', 'packageB2'))
        src1 = WppPackage('src1')
        src1.read(pathSrc)
        self.assertIn('packageA', src1.dictionary)
        self.assertIn('packageB', src1.dictionary)
        self.assertIn('packageA1', src1.dictionary['packageA'].dictionary)

        # Создать иерархию для Python
        core = PyCore()
        dst1 = src1.clone(core)
        self.assertEqual(dst1.name, 'src1')
        dst1.name = 'dst1'
        self.assertEqual(dst1.type, 'Package')
        self.assertIn('packageA', dst1.dictionary)
        self.assertIn('packageB', dst1.dictionary)
        self.assertIn('packageA1', dst1.dictionary['packageA'].dictionary)

        outContext = OutContextFolder(path0)
        dst1.export(outContext)
        self.assertTrue(os.path.isdir(pathDst))
        self.assertTrue(os.path.isfile(os.path.join(pathDst, iniName)))
        self.assertTrue(os.path.isdir(os.path.join(pathDst, 'packageA')))
        self.assertTrue(
            os.path.isfile(os.path.join(pathDst, 'packageA', iniName)))
        self.assertTrue(
            os.path.isdir(os.path.join(pathDst, 'packageA', 'packageA1')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(pathDst, 'packageA', 'packageA1', iniName)))