def test_convert_invalid_filename(): try: cli.convert('invalid_filename.pdf', 'pdf', 'emf') except typer.Exit: assert True else: assert False
def test_convert_no_filename(): try: cli.convert(None, None, 'emf') except typer.Exit: assert True else: assert False
def test_convert_invalid_formats(): try: cli.convert(None, 'invalid_format_1', 'invalid_format_2') except typer.Exit: assert True else: assert False
def test_convert(pdf_file_single): new_file = pdf_file_single.replace('.pdf', '.emf') cli.convert(pdf_file_single, from_format=None, to_format='emf') assert Path(new_file).exists() Path(new_file).unlink() cli.convert(pdf_file_single, from_format='pdf', to_format='emf') assert Path(new_file).exists() Path(new_file).unlink()
def test_convert_several(file_dir, ps_file_single, ps_file_multi): cwd = Path().cwd() os.chdir(file_dir) relevant_files = [ this_file for this_file in Path().iterdir() if str(this_file).lower().endswith('.ps') ] cli.convert(None, 'ps', 'pdf') new_files = [ Path(str(new_file).lower().replace('.ps', '.pdf')) for new_file in relevant_files ] new_files_exist = [ new_file.exists() for new_file in new_files ] assert all(new_files_exist) for new_file in new_files: new_file.unlink() os.chdir(cwd)