def test_to_skip(self): with utils.tmp_dir(): # Create input files and directories. fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input')) fw.mkdir('.git') fw.write(os.path.join('.git', 'index')) fw.write('somefile') fw.write('.DS_STORE') fw.write('leftover.pyc') fw.write('.pycfile') # Zip, unzip. zip_utils.zip('input', 'test.zip', to_skip=['.git', '.DS*', '*.pyc']) zip_utils.unzip('test.zip', 'output') # Remove the files/dirs we don't expect to see in output, so that we can # use self._compare_trees to check the results. fw.remove(os.path.join('.git', 'index')) fw.remove('.git') fw.remove('.DS_STORE') fw.remove('leftover.pyc') # Compare results. test_utils.compare_trees(self, 'input', 'output')
def _test_upload_download(self, store): with utils.tmp_dir(): # Create input files and directories. input_dir = os.path.join(os.getcwd(), 'input') _write_stuff(input_dir) # Upload a version, download it again. store.upload(self.asset_name, 0, input_dir) output_dir = os.path.join(os.getcwd(), 'output') store.download(self.asset_name, 0, output_dir) # Compare. test_utils.compare_trees(self, input_dir, output_dir)
def test_upload_download(self): with utils.tmp_dir(): # Create input files and directories. input_dir = os.path.join(os.getcwd(), 'input') _write_stuff(input_dir) # Upload a version, download it again. self.a.upload_new_version(input_dir) output_dir = os.path.join(os.getcwd(), 'output') self.a.download_current_version(output_dir) # Compare. test_utils.compare_trees(self, input_dir, output_dir)
def test_zip_unzip(self): with utils.tmp_dir(): fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input')) # Create input files and directories. fw.mkdir('mydir') fw.mkdir('anotherdir', 0o666) fw.mkdir('dir3', 0o600) fw.mkdir('subdir') fw.write('a.txt', 0o777) fw.write('b.txt', 0o751) fw.write('c.txt', 0o640) fw.write(os.path.join('subdir', 'd.txt'), 0o640) # Zip, unzip. zip_utils.zip('input', 'test.zip') zip_utils.unzip('test.zip', 'output') # Compare the inputs and outputs. test_utils.compare_trees(self, 'input', 'output')
def test_zip_unzip(self): with utils.tmp_dir(): fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input')) # Create input files and directories. fw.mkdir('mydir') fw.mkdir('anotherdir', 0666) fw.mkdir('dir3', 0600) fw.mkdir('subdir') fw.write('a.txt', 0777) fw.write('b.txt', 0751) fw.write('c.txt', 0640) fw.write(os.path.join('subdir', 'd.txt'), 0640) # Zip, unzip. zip_utils.zip('input', 'test.zip') zip_utils.unzip('test.zip', 'output') # Compare the inputs and outputs. test_utils.compare_trees(self, 'input', 'output')
def test_blacklist(self): with utils.tmp_dir(): # Create input files and directories. fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input')) fw.mkdir('.git') fw.write(os.path.join('.git', 'index')) fw.write('somefile') fw.write('.DS_STORE') fw.write('leftover.pyc') fw.write('.pycfile') # Zip, unzip. zip_utils.zip('input', 'test.zip', blacklist=['.git', '.DS*', '*.pyc']) zip_utils.unzip('test.zip', 'output') # Remove the files/dirs we don't expect to see in output, so that we can # use self._compare_trees to check the results. fw.remove(os.path.join('.git', 'index')) fw.remove('.git') fw.remove('.DS_STORE') fw.remove('leftover.pyc') # Compare results. test_utils.compare_trees(self, 'input', 'output')