Example #1
0
    def test_resolve_path(self):
        with self.create_fixture_folder() as folder:
            res = resolve_path(folder, '')
            self.assertEqual(folder, res)

            res = resolve_path(folder, '/')
            self.assertEqual(folder, res)
Example #2
0
    def test_resolve_path(self):
        with self.create_fixture_folder() as folder:
            res = resolve_path(folder, '')
            self.assertEquals(folder, res)

            res = resolve_path(folder, '/')
            self.assertEquals(folder, res)
Example #3
0
    def test_build_typical(self):
        from oxt_tool.package import build
        from oxt_tool.storage import makedirs_to_file

        manifest = Manifest()
        description = Description()

        import os.path
        import shutil
        src_folder_path = self.id()
        if os.path.exists(src_folder_path):
            shutil.rmtree(src_folder_path)
        src_folder = FileSystemStorage(src_folder_path, 'w')

        license_path = 'COPYING'
        license_node = makedirs_to_file(src_folder, license_path)
        with license_node.open('w') as f:
            f.write('GNU AGPL')
        description.license['en'] = license_path

        oxt_path = self.id() + '.oxt'

        files = {license_path: license_node}
        build(oxt_path, manifest, description, files=files)

        with open_storage(oxt_path) as pkg:
            with resolve_path(pkg, 'COPYING').open() as f:
                self.assertEquals('GNU AGPL', f.read())
Example #4
0
    def test_build_typical(self):
        from oxt_tool.package import build
        from oxt_tool.storage import makedirs_to_file

        manifest = Manifest()
        description = Description()

        import os.path
        import shutil
        src_folder_path = self.id()
        if os.path.exists(src_folder_path):
            shutil.rmtree(src_folder_path)
        src_folder = FileSystemStorage(src_folder_path, 'w')

        license_path = 'COPYING'
        license_node = makedirs_to_file(src_folder, license_path)
        with license_node.open('w') as f:
            f.write('GNU AGPL')
        description.license['en'] = license_path

        oxt_path = self.id() + '.oxt'

        files = {license_path: license_node}
        build(oxt_path, manifest, description, files=files)

        with open_storage(oxt_path) as pkg:
            with resolve_path(pkg, 'COPYING').open() as f:
                self.assertEqual('GNU AGPL', f.read())
Example #5
0
    def test_makedirs(self):
        import os.path

        dirname = '1'
        path = os.path.join(dirname, 'marker')
        with self.create_fixture_folder() as folder:
            res = makedirs(folder, '')
            self.assertEqual(folder, res)

            fld = makedirs(folder, dirname)
            with fld.file('marker').open('w') as f:
                f.write(dirname)
        with self.get_fixture_folder() as folder:
            node = resolve_path(folder, path)
            with node.open() as f:
                self.assertEqual(dirname, f.read())

        dirname = os.path.join(dirname, '2')
        path = os.path.join(dirname, 'marker')
        with self.create_fixture_folder() as folder:
            fld = makedirs(folder, dirname)
            with fld.file('marker').open('w') as f:
                f.write(dirname)
        with self.get_fixture_folder() as folder:
            node = resolve_path(folder, path)
            with node.open() as f:
                self.assertEqual(dirname, f.read())

        # on existing non-folder
        dirname = 'bar.txt'
        with self.create_fixture_folder() as folder:
            try:
                makedirs(folder, dirname)
                assert False, 'exception expected'
            except:
                pass

        # under existing non-folder
        dirname = os.path.join(dirname, 'should-fail')
        with self.create_fixture_folder() as folder:
            try:
                makedirs(folder, dirname)
                assert False, 'exception expected'
            except:
                pass
        with self.get_fixture_folder() as folder:
            self.assertEqual(None, resolve_path(folder, dirname))
Example #6
0
    def test_makedirs(self):
        import os.path

        dirname = '1'
        path = os.path.join(dirname, 'marker')
        with self.create_fixture_folder() as folder:
            res = makedirs(folder, '')
            self.assertEquals(folder, res)

            fld = makedirs(folder, dirname)
            with fld.file('marker').open('w') as f:
                f.write(dirname)
        with self.get_fixture_folder() as folder:
            node = resolve_path(folder, path)
            with node.open() as f:
                self.assertEquals(dirname, f.read())

        dirname = os.path.join(dirname, '2')
        path = os.path.join(dirname, 'marker')
        with self.create_fixture_folder() as folder:
            fld = makedirs(folder, dirname)
            with fld.file('marker').open('w') as f:
                f.write(dirname)
        with self.get_fixture_folder() as folder:
            node = resolve_path(folder, path)
            with node.open() as f:
                self.assertEquals(dirname, f.read())

        # on existing non-folder
        dirname = 'bar.txt'
        with self.create_fixture_folder() as folder:
            try:
                makedirs(folder, dirname)
                assert False, 'exception expected'
            except:
                pass

        # under existing non-folder
        dirname = os.path.join(dirname, 'should-fail')
        with self.create_fixture_folder() as folder:
            try:
                makedirs(folder, dirname)
                assert False, 'exception expected'
            except:
                pass
        with self.get_fixture_folder() as folder:
            self.assertEquals(None, resolve_path(folder, dirname))
Example #7
0
 def test_makedirs_to_file(self):
     import os.path
     path = os.path.join('hello', 'world', 'makedirs')
     with self.create_fixture_folder() as folder:
         node = makedirs_to_file(folder, path)
         with node.open('w'):
             pass
     with self.get_fixture_folder() as folder:
         node = resolve_path(folder, path)
         self.assertTrue(node is not None)
Example #8
0
 def test_makedirs_to_file(self):
     import os.path
     path = os.path.join('hello', 'world', 'makedirs')
     with self.create_fixture_folder() as folder:
         node = makedirs_to_file(folder, path)
         with node.open('w'):
             pass
     with self.get_fixture_folder() as folder:
         node = resolve_path(folder, path)
         self.assertTrue(node is not None)