

def testDownloadCollectionWithFlattenOption(self):
    'Check we can download files references in RDFValueCollection.'
    fd = aff4.FACTORY.Create('aff4:/testcoll', 'RDFValueCollection', token=self.token)
    fd.Add(rdfvalue.RDFURN(self.out.Add('testfile1')))
    fd.Add(rdf_client.StatEntry(aff4path=self.out.Add('testfile2')))
    fd.Add(file_finder.FileFinderResult(stat_entry=rdf_client.StatEntry(aff4path=self.out.Add('testfile5'))))
    fd.Close()
    with utils.TempDirectory() as tmpdir:
        export_utils.DownloadCollection('aff4:/testcoll', fd, overwrite=True, dump_client_info=True, flatten=True, token=self.token, max_threads=2)
        symlinks = os.listdir(os.path.join(tmpdir, 'files'))
        self.assertEqual(len(symlinks), 3)
        self.assertListEqual(sorted(symlinks), ['C.1000000000000000_fs_os_testfile1', 'C.1000000000000000_fs_os_testfile2', 'C.1000000000000000_fs_os_testfile5'])
        self.assertEqual(os.readlink(os.path.join(tmpdir, 'files', 'C.1000000000000000_fs_os_testfile1')), os.path.join(tmpdir, 'C.1000000000000000', 'fs', 'os', 'testfile1'))

dataset/ETHPy150Open google/grr/grr/lib/export_utils_test.py TestExports.testDownloadCollectionWithFlattenOption/VarMisuse@122/196 `tmpdir`->`fd`