def test_copy(self, with_local_folders): original_file_path = local_storage.write(self._get_file_data(), local_storage.PERM, self.temp_file_name) original_file = open(original_file_path, 'rb') original_checksum = hashlib.md5(original_file.read()).hexdigest() original_file.close() copied_file_path = local_storage.copy(local_storage.PERM, local_storage.REJECT, self.temp_file_name) assert os.path.basename(original_file_path) == os.path.basename( copied_file_path) assert original_file_path != copied_file_path with pytest.raises(FileNotFoundError): open(original_file_path, 'rb') copied_file = open(copied_file_path, 'rb') # Checksum confirmation! assert original_checksum == hashlib.md5(copied_file.read()).hexdigest() copied_file.close()
def test_write(self, with_local_folders): file_name = local_storage.write(self._get_file_data(), local_storage.PERM, self.temp_file_name) assert self.temp_file_name == os.path.basename(file_name) assert os.path.isfile(file_name)
def test_write_return(self, isdir, open_mock): """ Write method returns a file name """ result = local_storage.write(self._get_file_data(), local_storage.PERM, self.temp_file_name) assert result == open_mock.return_value.__enter__.return_value.name
def test_write_no_folders_at_all(self, no_local_folders): file_name = local_storage.write(self._get_file_data(), local_storage.QUARANTINE, self.temp_file_name) assert self.temp_file_name == os.path.basename(file_name) assert os.path.isfile(file_name)
def test_copy(self, with_local_folders, local_file): original_file_path = local_storage.write( local_file, local_storage.PERM, self.temp_file_name, config.DUMMY_VALUES['account'], "curl/7.61.1") original_file = open(original_file_path, 'rb') original_checksum = hashlib.md5(original_file.read()).hexdigest() original_file.close() copied_file_path = local_storage.copy(local_storage.PERM, local_storage.REJECT, self.temp_file_name) assert os.path.basename(original_file_path) == os.path.basename( copied_file_path) assert original_file_path != copied_file_path with pytest.raises(FileNotFoundError): open(original_file_path, 'rb') copied_file = open(copied_file_path, 'rb') # Checksum confirmation! assert original_checksum == hashlib.md5(copied_file.read()).hexdigest() copied_file.close()
def test_write(self, with_local_folders, local_file): file_name = local_storage.write(local_file, local_storage.PERM, self.temp_file_name, config.DUMMY_VALUES['account'], "curl/7.61.1") assert self.temp_file_name == os.path.basename(file_name) assert os.path.isfile(file_name)
def test_write_return(self, isdir, open_mock, local_file): """ Write method returns a file name """ result = local_storage.write(local_file, local_storage.PERM, self.temp_file_name, config.DUMMY_VALUES['account'], "curl/7.61.1") assert result == open_mock.return_value.__enter__.return_value.name
def test_ls(self, with_local_folders): local_storage.write(self._get_file_data(), local_storage.PERM, self.temp_file_name) assert local_storage.ls(local_storage.PERM, self.temp_file_name) is True
def test_write_wrong_destination(self, with_local_folders): with pytest.raises(FileNotFoundError): local_storage.write(self._get_file_data(), self.non_existing_folder, self.temp_file_name)
def test_ls(self, with_local_folders, local_file): local_storage.write(local_file, local_storage.PERM, self.temp_file_name, config.DUMMY_VALUES['account'], "curl/7.61.1") assert local_storage.ls(local_storage.PERM, self.temp_file_name) is True
def test_write_wrong_destination(self, with_local_folders, local_file): with pytest.raises(FileNotFoundError): local_storage.write(local_file, self.non_existing_folder, self.temp_file_name, config.DUMMY_VALUES['account'], "curl/7.61.1")