def _testDownloadMultiFileItem(self, item, user, contents, format=None):
    params = None
    if format:
        params = {'format': format}
    resp = self.request(path=('/item/%s/download' % item['_id']), method='GET', user=user, isJson=False, params=params)
    self.assertStatusOk(resp)
    zipFile = zipfile.ZipFile(io.BytesIO(self.getBody(resp, text=False)), 'r')
    prefix = os.path.split(zipFile.namelist()[0])[0]
    expectedZip = {}
    for name in contents:
        expectedZip[os.path.join(prefix, name)] = contents[name]
    self.assertHasKeys(expectedZip, zipFile.namelist())
    self.assertHasKeys(zipFile.namelist(), expectedZip)
    for name in zipFile.namelist():
        expected = expectedZip[name]
        if (not isinstance(expected, six.binary_type)):
            expected = expected.encode('utf8')
        self.assertEqual(expected, zipFile.read(name))
def _testDownloadMultiFileItem(self, item, user, contents, format=None):
    params = None
    if format:
        params = {'format': format}
    resp = self.request(path=('/item/%s/download' % item['_id']), method='GET', user=user, isJson=False, params=params)
    self.assertStatusOk(resp)
    zipFile = zipfile.ZipFile(io.BytesIO(self.getBody(resp, text=False)), 'r')
    prefix = os.path.split(zipFile.namelist()[0])[0]
    expectedZip = {}
    for name in contents:
        expectedZip[os.path.join(prefix, name)] = contents[name]
    self.assertHasKeys(expectedZip, zipFile.namelist())
    self.assertHasKeys(zipFile.namelist(), expectedZip)
    for name in zipFile.namelist():
        expected = expectedZip[name]
        if (not isinstance(expected, six.binary_type)):
            expected = expected.encode('utf8')
        self.assertEqual(expected, zipFile.read(name))