示例#1
0
    def test_download_tarfile(self):
        # this is done after the small file sorting happens,
        # so pick UUIDs that would be grouped together
        files_to_dl = ['small_no_friends']

        index_client = GDCIndexClient(base_url)
        index_client._get_metadata(files_to_dl)

        client = GDCHTTPDownloadClient(uri=base_url,
                                       index_client=index_client,
                                       **client_kwargs)

        # it will remove redundant uuids
        tarfile_name, errors = client._download_tarfile(files_to_dl)

        assert tarfile_name != None
        assert os.path.exists(tarfile_name)
        assert tarfile.is_tarfile(tarfile_name) == True

        with tarfile.open(tarfile_name, 'r') as t:
            for member in t.getmembers():
                m = t.extractfile(member)
                contents = m.read()
                assert contents == uuids[m.name]['contents']
                os.remove(tarfile_name)
示例#2
0
    def test_rel_mock_get_metadata(self):
        index = GDCIndexClient(uri=base_url)
        index._get_metadata(['small_rel'])

        assert index.get_access('small_rel') == uuids['small_rel']['access']
        assert index.get_filesize('small_rel') == uuids['small_rel']['file_size']
        assert index.get_md5sum('small_rel') == uuids['small_rel']['md5sum']
        assert index.get_related_files('small_rel') == uuids['small_rel']['related_files']
        assert index.get_annotations('small_rel') == []
示例#3
0
    def test_md5_members(self):

        files_to_tar = ['small', 'small_ann', 'small_rel', 'small_no_friends']

        tarfile_name = make_tarfile(files_to_tar)

        index_client = GDCIndexClient(base_url)
        index_client._get_metadata(files_to_tar)

        client = GDCHTTPDownloadClient(uri=base_url,
                                       index_client=index_client,
                                       **client_kwargs)

        client._untar_file(tarfile_name)
        errors = client._md5_members(files_to_tar)

        assert errors == []

        for f in files_to_tar:
            os.path.exists(f)
            os.remove(f)