示例#1
0
    def test_tarfile_root_owner(self):
        tmpdir, tmpdir2, base_name = self._create_files()
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        group = grp.getgrgid(0)[0]
        owner = pwd.getpwuid(0)[0]
        try:
            archive_name = _make_tarball(base_name,
                                         'dist',
                                         compress=None,
                                         owner=owner,
                                         group=group)
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        self.assertTrue(os.path.exists(archive_name))

        # now checks the rights
        archive = tarfile.open(archive_name)
        try:
            for member in archive.getmembers():
                self.assertEqual(member.uid, 0)
                self.assertEqual(member.gid, 0)
        finally:
            archive.close()
示例#2
0
 def _tarinfo(self, path):
     tar = tarfile.open(path)
     try:
         names = tar.getnames()
         names.sort()
         return tuple(names)
     finally:
         tar.close()
示例#3
0
 def _tarinfo(self, path):
     tar = tarfile.open(path)
     try:
         names = tar.getnames()
         names.sort()
         return tuple(names)
     finally:
         tar.close()
    def test_convert(self, hepdata_input_tar, yaml_path):
        r = self.app_client.get('/convert', data=json.dumps({'input': hepdata_input_tar.decode('utf-8'),
                                                      'options': {'input_format': 'oldhepdata', 'output_format': 'yaml'}}),
                         headers={'content-type': 'application/json'})

        with tarfile.open(mode='r:gz', fileobj=BytesIO(r.data)) as tar:
            tar.extractall(path=self.current_tmp)

        self.assertDirsEqual(os.path.join(self.current_tmp, 'hepdata-converter-ws-data'), yaml_path)
    def test_convert(self, hepdata_input_tar, yaml_path):
        r = self.app_client.get('/convert', data=json.dumps({'input': hepdata_input_tar,
                                                      'options': {'input_format': 'oldhepdata', 'output_format': 'yaml'}}),
                         headers={'content-type': 'application/json'})

        with tarfile.open(mode='r:gz', fileobj=cStringIO.StringIO(r.data)) as tar:
            tar.extractall(path=self.current_tmp)

        self.assertDirsEqual(os.path.join(self.current_tmp, 'hepdata-converter-ws-data'), yaml_path)
    def test_convert_yaml_v0(self, hepdata_input_tar, csv_content, yaml_path):
        r = self.app_client.get(
            '/convert',
            data=json.dumps({
                'input': hepdata_input_tar.decode('utf-8'),
                'options': {
                    'input_format': 'yaml',
                    'output_format': 'csv',
                    'table': 'Table 1',
                    'pack': True,
                    'validator_schema_version': '0.1.0'
                }
            }),
            headers={'content-type': 'application/json'})

        with tarfile.open(mode='r:gz', fileobj=BytesIO(r.data)) as tar:
            tar.extractall(path=self.current_tmp)

        self.assertEqual(len(os.listdir(self.current_tmp)), 1)
        output_file_path = os.path.join(self.current_tmp, os.listdir(self.current_tmp)[0])

        with open(output_file_path, 'r') as f:
            self.assertMultiLineAlmostEqual(f, csv_content)
示例#7
0
    def test_tarfile_root_owner(self):
        tmpdir, tmpdir2, base_name =  self._create_files()
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        group = grp.getgrgid(0)[0]
        owner = pwd.getpwuid(0)[0]
        try:
            archive_name = _make_tarball(base_name, 'dist', compress=None,
                                         owner=owner, group=group)
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        self.assertTrue(os.path.exists(archive_name))

        # now checks the rights
        archive = tarfile.open(archive_name)
        try:
            for member in archive.getmembers():
                self.assertEqual(member.uid, 0)
                self.assertEqual(member.gid, 0)
        finally:
            archive.close()