def test_add_to_zip_dir(self): """ Test that files are saved under specified directory """ zipfile_str, zipfile = self.test_start_zip_dir() file_contents, dir = dict(c='file c contents', d='file d contents'), 'dir' zipfile = utils.add_to_zip(zipfile, file_contents, dir) zipinfo = zipfile.infolist() zipnames = [z.filename for z in zipinfo] assert 'dir/c' in zipnames assert 'dir/d' in zipnames
def test_add_to_zip_filecontents(self): """ Test that zip is initialized with file contents dict properly """ zipfile_str, zipfile = self.test_start_zip_filecontents() file_contents = dict(c='file c contents', d='file d contents') zipfile = utils.add_to_zip(zipfile, file_contents) zipinfo = zipfile.infolist() zipnames = [z.filename for z in zipinfo] assert 'c' in zipnames assert 'c' in zipnames
def test_add_to_zip_basic(self): """ Test that a zip is added to properly """ zipfile_str, zipfile = self.test_start_zip_basic() zipfile = utils.add_to_zip(zipfile, dict(filename='file contents')) assert len(zipfile.infolist()) == 1 return zipfile_str, zipfile