def test_merge_and_extract_new_file(self, tmp_path): env = Environment(tmp_path) parameters = [{ 'custom_content_object': env.INTEGRATION_CUSTOM_CONTENT_OBJECT, 'raw_files': [ 'odp/bn.py', 'odp/bn.yml', 'odp/bn_image.png', 'odp/bn_description.md', 'odp/README.md' ] }, { 'custom_content_object': env.SCRIPT_CUSTOM_CONTENT_OBJECT, 'raw_files': ['odp/bn.py', 'odp/bn.yml', 'odp/README.md'] }] for param in parameters: temp_dir = env.tmp_path / f'temp_dir_{parameters.index(param)}' os.mkdir(temp_dir) entity = param['custom_content_object']['entity'] downloader = Downloader(output=str(temp_dir), input='', regex='') basename = downloader.create_dir_name( param['custom_content_object']['name']) output_entity_dir_path = f'{temp_dir}/{entity}' os.mkdir(output_entity_dir_path) output_dir_path = f'{output_entity_dir_path}/{basename}' os.mkdir(output_dir_path) files = [ file.replace('odp', output_dir_path).replace('bn', basename) for file in param['raw_files'] ] downloader.merge_and_extract_new_file( param['custom_content_object']) output_files = get_child_files(output_dir_path) assert sorted(output_files) == sorted(files)
def test_merge_and_extract_new_file(self, custom_content_object, raw_files): env_guard = EnvironmentGuardian() temp_dir = mkdtemp() entity = custom_content_object['entity'] downloader = Downloader(output=temp_dir, input='') basename = downloader.create_dir_name(custom_content_object['name']) output_entity_dir_path = f'{temp_dir}/{entity}' os.mkdir(output_entity_dir_path) output_dir_path = f'{output_entity_dir_path}/{basename}' os.mkdir(output_dir_path) files = [file.replace('odp', output_dir_path).replace('bn', basename) for file in raw_files] downloader.merge_and_extract_new_file(custom_content_object) output_files = get_child_files(output_dir_path) test_answer = sorted(output_files) == sorted(files) env_guard.restore_environment('test_merge_and_extract_new_file', temp_dir) assert test_answer
def test_create_dir_name(self, name): downloader = Downloader(output='', input='', regex='') assert downloader.create_dir_name(name) == 'GSM'