コード例 #1
0
    def test_import_default_settings(self):
        """Import a Zip file.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test1.zip') as archive:
            succeeded, failed = importer.importArchive(archive)

        self.assertItemsEqual(succeeded, [
            'testzip/foo/bar/baz/image5.jpg', 'testzip/foo/bar/image4.jpg',
            'testzip/foo/image3.jpg', 'testzip/bar/image2.jpg',
            'testzip/image1.jpg', 'testzip/sound1.mp3', 'testzip/Clock.swf'
        ])
        self.assertItemsEqual([], failed)

        self.assert_(folder['testzip'])
        self.assert_(folder['testzip']['bar'])
        self.assert_(folder['testzip']['foo'])
        self.assert_(folder['testzip']['foo']['bar'])
        self.assert_(folder['testzip']['foo']['bar']['baz'])

        self.assertTrue(
            interfaces.IImage.providedBy(folder['testzip']['image1.jpg']))
        self.assertTrue(
            interfaces.IFile.providedBy(folder['testzip']['sound1.mp3']))
        self.assertTrue(
            interfaces.IFile.providedBy(folder['testzip']['Clock.swf']))
        self.assertTrue(
            interfaces.IImage.providedBy(
                folder['testzip']['bar']['image2.jpg']))
        self.assertTrue(
            interfaces.IImage.providedBy(
                folder['testzip']['foo']['bar']['baz']['image5.jpg']))
コード例 #2
0
    def test_import_default_settings(self):
        """Import a Zip file.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test1.zip') as archive:
            succeeded, failed = importer.importArchive(archive)

        self.assertItemsEqual(
            succeeded,
            ['testzip/foo/bar/baz/image5.jpg',
             'testzip/foo/bar/image4.jpg',
             'testzip/foo/image3.jpg',
             'testzip/bar/image2.jpg',
             'testzip/image1.jpg',
             'testzip/sound1.mp3',
             'testzip/Clock.swf'])
        self.assertItemsEqual([], failed)

        self.assert_(folder['testzip'])
        self.assert_(folder['testzip']['bar'])
        self.assert_(folder['testzip']['foo'])
        self.assert_(folder['testzip']['foo']['bar'])
        self.assert_(folder['testzip']['foo']['bar']['baz'])

        self.assertTrue(interfaces.IImage.providedBy(
                folder['testzip']['image1.jpg']))
        self.assertTrue(interfaces.IFile.providedBy(
                folder['testzip']['sound1.mp3']))
        self.assertTrue(interfaces.IFile.providedBy(
                folder['testzip']['Clock.swf']))
        self.assertTrue(interfaces.IImage.providedBy(
                folder['testzip']['bar']['image2.jpg']))
        self.assertTrue(interfaces.IImage.providedBy(
                folder['testzip']['foo']['bar']['baz']['image5.jpg']))
コード例 #3
0
    def test_import_asset_set_title(self):
        """Set a default title to the imported assets.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test1.zip') as archive:
            succeeded, failed = importer.importArchive(
                archive, assettitle=u'Daarhelemali')

        self.assertItemsEqual(failed, [])
        self.assertEqual(u'Daarhelemali',
                         folder['testzip']['bar']['image2.jpg'].get_title())
        self.assertEqual(
            u'Daarhelemali',
            folder['testzip']['foo']['bar']['baz']['image5.jpg'].get_title())
コード例 #4
0
    def test_import_asset_set_title(self):
        """Set a default title to the imported assets.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test1.zip') as archive:
            succeeded, failed = importer.importArchive(
                archive, assettitle=u'Daarhelemali')

        self.assertItemsEqual(failed, [])
        self.assertEqual(
            u'Daarhelemali',
            folder['testzip']['bar']['image2.jpg'].get_title())
        self.assertEqual(
            u'Daarhelemali',
            folder['testzip']['foo']['bar']['baz']['image5.jpg'].get_title())
コード例 #5
0
    def test_import_macos_files(self):
        """Import an archive file that have Macos X metadata
        directories. They should be ignored.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test3.zip') as archive:
            succeeded, failed = importer.importArchive(archive)

        self.assertItemsEqual(succeeded, ['imgs/c16.png', 'imgs/c17.png'])
        self.assertItemsEqual([], failed)

        self.assertItemsEqual(folder.objectIds(), ['imgs'])
        self.assertItemsEqual(folder.imgs.objectIds(), ['c16.png', 'c17.png'])

        self.assertTrue(interfaces.IImage.providedBy(
            folder['imgs']['c16.png']))
        self.assertTrue(interfaces.IImage.providedBy(
            folder['imgs']['c17.png']))
コード例 #6
0
    def test_import_macos_files(self):
        """Import an archive file that have Macos X metadata
        directories. They should be ignored.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test3.zip') as archive:
            succeeded, failed = importer.importArchive(archive)

        self.assertItemsEqual(succeeded, ['imgs/c16.png', 'imgs/c17.png'])
        self.assertItemsEqual([], failed)

        self.assertItemsEqual(folder.objectIds(), ['imgs'])
        self.assertItemsEqual(folder.imgs.objectIds(), ['c16.png', 'c17.png'])

        self.assertTrue(interfaces.IImage.providedBy(
                folder['imgs']['c16.png']))
        self.assertTrue(interfaces.IImage.providedBy(
                folder['imgs']['c17.png']))
コード例 #7
0
    def test_import_no_sub_dirs(self):
        """Import a Zip that doesn't have any subdirectories.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test2.zip') as archive:
            succeeded, failed = importer.importArchive(archive)

        self.assertItemsEqual(succeeded,
                              ['Clock.swf', 'image1.jpg', 'sound1.mp3'])
        self.assertItemsEqual(failed, [])

        self.assertItemsEqual(succeeded,
                              ['Clock.swf', 'image1.jpg', 'sound1.mp3'])
        self.assertItemsEqual([], failed)
        self.assertItemsEqual(folder.objectIds(),
                              ['Clock.swf', 'image1.jpg', 'sound1.mp3'])
        self.assertTrue(interfaces.IImage.providedBy(folder['image1.jpg']))
        self.assertTrue(interfaces.IFile.providedBy(folder['sound1.mp3']))
        self.assertTrue(interfaces.IFile.providedBy(folder['Clock.swf']))
コード例 #8
0
    def test_import_no_sub_dirs(self):
        """Import a Zip that doesn't have any subdirectories.
        """
        folder = self.root.folder
        importer = IArchiveFileImporter(folder)
        with self.layer.open_fixture('test2.zip') as archive:
            succeeded, failed = importer.importArchive(archive)

        self.assertItemsEqual(
            succeeded, ['Clock.swf', 'image1.jpg', 'sound1.mp3'])
        self.assertItemsEqual(failed, [])

        self.assertItemsEqual(
            succeeded, ['Clock.swf', 'image1.jpg', 'sound1.mp3'])
        self.assertItemsEqual([], failed)
        self.assertItemsEqual(
            folder.objectIds(), ['Clock.swf', 'image1.jpg', 'sound1.mp3'])
        self.assertTrue(interfaces.IImage.providedBy(folder['image1.jpg']))
        self.assertTrue(interfaces.IFile.providedBy(folder['sound1.mp3']))
        self.assertTrue(interfaces.IFile.providedBy(folder['Clock.swf']))