def process_task(file_ids_list=None): files_to_process = boilerplate.list_files(recursive=True, prefix=boilerplate.UPLOAD_PREFIX) if file_ids_list: files_to_process = [ boilerplate.UPLOAD_PREFIX + file_id for file_id in file_ids_list if (boilerplate.UPLOAD_PREFIX + file_id) in files_to_process ] data_to_process = { file_id[len(boilerplate.UPLOAD_PREFIX):]: boilerplate.get_file(file_id) for file_id in files_to_process } processed_file_ids = list() for processed_file_id, contents in process_data(data_to_process): processed_file_ids.append( boilerplate.add_processed_file(processed_file_id, contents, extension='txt')) return processed_file_ids
def test_process_data_bad_values(): with pytest.raises(AttributeError): assert [contents for _, contents in process_data({"test": 1})]
def test_process_data(input_data, expected_result): processed_data = [contents for _, contents in process_data(input_data)] assert processed_data == expected_result