def convert_substructure_images_bad_permissions_test(): # If we do not have permissions to write to the unafold # directory, we need to trhow a runtimeError temp_dir = tempfile.mkdtemp() subprocess.call(["chmod", "a-w", temp_dir]) try: weboutput.convert_substructure_images(temp_dir, "/tmp") finally: shutil.rmtree(temp_dir)
def convert_substructure_images_no_output_dir_test(): # If we call convert_substructure_images and output_dir # does not exist, then it should throw a # RuntimeError testps = """ %! /Helvetica findfont 72 scalefont setfont 72 72 moveto (Hello, world!) show showpage """ output_dir = "/tmp/does_not_exist" # This function needs to find at least one structure image to # convert. unafold_dir = tempfile.mkdtemp() with open(os.path.join(unafold_dir, "test.ps"), "w") as testpsfile: testpsfile.write(testps) try: weboutput.convert_substructure_images(unafold_dir, output_dir) finally: shutil.rmtree(unafold_dir)
def convert_substructure_images_bad_output_dir_permissions_test(): testps = """ %! /Helvetica findfont 72 scalefont setfont 72 72 moveto (Hello, world!) show showpage """ # If we do not have permissions to write to the output # directory, we need to trhow a runtimeError output_dir = tempfile.mkdtemp() subprocess.call(["chmod", "a-w", output_dir]) # This function needs to find at least one structure image to # convert. unafold_dir = tempfile.mkdtemp() with open(os.path.join(unafold_dir, "test.ps"), "w") as testpsfile: testpsfile.write(testps) try: weboutput.convert_substructure_images(unafold_dir, output_dir) finally: shutil.rmtree(unafold_dir) shutil.rmtree(output_dir)
def convert_substructure_images_no_unafold_dir_test(): # If we call convert_substructure_images and temp_directory # does not exist, then it should throw a # RuntimeError temp_dir = "/tmp/does_not_exist" weboutput.convert_substructure_images(temp_dir, "/tmp")