def test_do_rebuild_bad_file(self): # refactor bad_file = temp_file(contents=random_text()) file_hash = file_sha256(bad_file) metadata = self.meta_service.create_metadata(bad_file) endpoint = f'http://{self.sdk_server}:{self.sdk_port}' dir = metadata.metadata_folder_path() result = self.file_processing.do_rebuild(endpoint=endpoint, hash=file_hash, source_path=bad_file, dir=dir) assert result == False metadata.load() assert metadata.data.get('error') == 'Engine response could not be decoded'
def test_create_metadata(self): metadata = self.metadata_service.create_metadata(self.test_file) metadata.delete() metadata.add_file(self.test_file) assert metadata.data == { 'file_name': file_name(self.test_file), 'xml_report_status': None, 'last_update_time': metadata.get_last_update_time(), 'rebuild_server': None, 'server_version': None, 'error': None, 'original_file_paths': [self.test_file], 'original_hash': file_sha256(self.test_file), 'original_hash_calculation_time': metadata.data.get('original_hash_calculation_time'), 'original_file_extension': '.jpg', 'original_file_size': 97610, 'rebuild_file_path': None, 'rebuild_hash': None, 'rebuild_status': FileStatus.INITIAL, 'rebuild_file_extension': None, 'rebuild_file_size': None, 'rebuild_file_duration': None, 'f2f_plugin_version': None, 'f2f_plugin_git_commit': None, 'hd1_to_hd2_copy_time': None, 'hd2_to_hd3_copy_time': None } assert metadata.delete() is True
def test_file_hash(self): hash = self.metadata_service.file_hash(self.test_file) assert hash == file_sha256(self.test_file)
def file_hash(self, file_path): if file_exists(file_path): return file_sha256(file_path)
def file_hash(self, file_path): return file_sha256(file_path)