def setUpClass(cls): cls.initial_directory = os.getcwd() os.chdir("vimiv/testimages") cls.settings = parse_config() paths, index = populate(["arch_001.jpg"]) cls.vimiv = v_main.Vimiv(cls.settings, paths, index) cls.vimiv.main()
def test_format_files(self): """Format files according to a formatstring.""" shutil.copytree("testimages/", "testimages_to_format/") os.chdir("testimages_to_format") settings = parse_config() paths, index = fileactions.populate(["arch_001.jpg"]) vimiv = v_main.Vimiv(settings, paths, index) vimiv.main() vimiv.fileextras.format_files("formatted_") files = [fil for fil in os.listdir() if "formatted_" in fil] files = sorted(files) expected_files = [ "formatted_001.jpg", "formatted_002", "formatted_003.bmp", "formatted_004.svg", "formatted_005.tiff", "formatted_006.png" ] self.assertEqual(files, expected_files) os.chdir("..") shutil.rmtree("testimages_to_format") # Should not work without a path vimiv.paths = [] vimiv.fileextras.format_files("formatted_") err_message = vimiv.statusbar.left_label.get_text() expected_message = "No files in path" self.assertEqual(expected_message, err_message) # Should not work in library vimiv.library.focus(True) vimiv.fileextras.format_files("formatted_") err_message = vimiv.statusbar.left_label.get_text() expected_message = "Format only works on opened image files" self.assertEqual(expected_message, err_message)
def setUpClass(cls): cls.working_directory = os.getcwd() os.chdir("vimiv") cls.settings = parse_config() cls.vimiv = v_main.Vimiv(cls.settings, "testimages", 0) cls.vimiv.main() cls.lib = cls.vimiv.library
def setUpClass(cls): cls.working_directory = os.getcwd() paths, index = populate(["vimiv/testimages/arch_001.jpg"], False, False) cls.settings = parse_config() cls.vimiv = v_main.Vimiv(cls.settings, paths, index) cls.vimiv.main()
def test_opening_recursively(self): """Open all images recursively.""" os.chdir("testimages") paths, index = populate([], True, False) vimiv = v_main.Vimiv(self.settings, paths, index) vimiv.main() self.assertEqual(8, len(vimiv.paths))
def setUpClass(cls): cls.working_directory = os.getcwd() os.chdir("vimiv") cls.settings = parse_config() paths, index = populate(["testimages/arch_001.jpg"]) cls.vimiv = v_main.Vimiv(cls.settings, paths, index) cls.slideshow = cls.vimiv.slideshow cls.vimiv.main()
def setUpClass(cls): cls.working_directory = os.getcwd() os.chdir("vimiv") cls.settings = parse_config() shutil.copytree("testimages", "testimages_man") paths, index = populate(["testimages_man/arch-logo.png"]) cls.vimiv = v_main.Vimiv(cls.settings, paths, index) cls.vimiv.main() cls.manipulate = cls.vimiv.manipulate
def setUpClass(cls): cls.working_directory = os.getcwd() os.chdir("vimiv") cls.settings = parse_config() paths, index = populate(["testimages"], False, False) cls.vimiv = v_main.Vimiv(cls.settings, paths, index) cls.vimiv.main() # Move away from directory cls.vimiv.library.scroll("j")
def setUpClass(cls): cls.working_directory = os.getcwd() os.chdir("vimiv") cls.settings = parse_config() paths, index = populate(["testimages/arch-logo.png"]) cls.vimiv = v_main.Vimiv(cls.settings, paths, index) cls.vimiv.main() cls.thumb = cls.vimiv.thumbnail cls.thumb.size = (128, 128) cls.thumb.max_size = (256, 256) cls.thumb.sizes = [(64, 64), (128, 128), (256, 256)]
def test_opening_with_symlink(self): """Open with a symlink to an image.""" expected_dir = os.path.abspath("./testimages") paths, index = populate(["testimages/symlink_to_image"], False, False) vimiv = v_main.Vimiv(self.settings, paths, index) vimiv.main() # Check moving and image population self.assertEqual(expected_dir, os.getcwd()) expected_images = ["symlink_to_image", "vimiv.bmp", "vimiv.svg", "vimiv.tiff", "arch-logo.png", "arch_001.jpg"] expected_images = [os.path.abspath(image) for image in expected_images] self.assertEqual(expected_images, vimiv.paths)
def test_opening_with_whitespace(self): """Open an image with whitespace and symlink in directory.""" expected_dir = os.path.abspath("./testimages/directory/") paths, index = \ populate(["testimages/directory/symlink with spaces .jpg"], False, False) vimiv = v_main.Vimiv(self.settings, paths, index) vimiv.main() # Check moving and image population self.assertEqual(expected_dir, os.getcwd()) expected_images = ["symlink with spaces .jpg"] expected_images = [os.path.abspath(image) for image in expected_images] self.assertEqual(expected_images, vimiv.paths)
def test_opening_with_directory(self): """Opening with a directory.""" expected_dir = os.path.abspath("./testimages") paths, index = populate(["testimages"], False, False) vimiv = v_main.Vimiv(self.settings, paths, index) vimiv.main() self.assertEqual(expected_dir, os.getcwd()) expected_files = ["animation", "arch-logo.png", "arch_001.jpg", "directory", "symlink_to_image", "vimiv.bmp", "vimiv.svg", "vimiv.tiff"] self.assertEqual(vimiv.library.files, expected_files) self.assertTrue(vimiv.library.treeview.is_focus()) self.assertTrue(vimiv.library.grid.is_visible())
def test_format_files_with_exif(self): """Format files according to a formatstring with EXIF data.""" shutil.copytree("testimages/", "testimages_to_format/") os.chdir("testimages_to_format") settings = parse_config() paths, index = fileactions.populate(["arch_001.jpg"]) vimiv = v_main.Vimiv(settings, paths, index) vimiv.main() vimiv.fileextras.format_files("formatted_") files = [fil for fil in os.listdir() if "formatted_" in fil] files = sorted(files) expected_files = [ "formatted_001.jpg", "formatted_002", "formatted_003.bmp", "formatted_004.svg", "formatted_005.tiff", "formatted_006.png" ] self.assertEqual(files, expected_files) # These files have no exif info vimiv.fileextras.format_files("formatted_%y_") err_message = vimiv.statusbar.left_label.get_text() expected_message = "No exif data for %s available" % \ (os.path.abspath("formatted_001.jpg")) self.assertEqual(expected_message, err_message) # Should not work without a path vimiv.paths = [] vimiv.fileextras.format_files("formatted_foo_") err_message = vimiv.statusbar.left_label.get_text() expected_message = "No files in path" self.assertEqual(expected_message, err_message) # Should not work in library vimiv.library.focus(True) vimiv.fileextras.format_files("formatted_bar_") err_message = vimiv.statusbar.left_label.get_text() expected_message = "Format only works on opened image files" self.assertEqual(expected_message, err_message) # Make sure nothing changed files = [fil for fil in os.listdir() if "formatted_" in fil] files = sorted(files) self.assertEqual(files, expected_files) # Clean up os.chdir("..") shutil.rmtree("testimages_to_format")
def test_clear(self): """Clear Trash/Thumbnails.""" settings = parse_config() vimiv = v_main.Vimiv(settings, [], 0) vimiv.main() thumbdir = os.path.expanduser("~/.vimiv/Thumbnails") trashdir = os.path.expanduser("~/.vimiv/Trash") if not os.path.isdir("Thumbnail_bak"): shutil.copytree(thumbdir, "Thumbnail_bak") if not os.path.isdir("Trash_bak"): shutil.copytree(trashdir, "Trash_bak") # Make sure there are some files in the directories os.system("touch ~/.vimiv/Trash/foo") os.system("touch ~/.vimiv/Thumbnails/foo") vimiv.fileextras.clear("Thumbnails") vimiv.fileextras.clear("Trash") self.assertEqual(os.listdir(thumbdir), []) self.assertEqual(os.listdir(trashdir), []) # Move backups back to directory shutil.rmtree(thumbdir) shutil.rmtree(trashdir) shutil.move("Thumbnail_bak", thumbdir) shutil.move("Trash_bak", trashdir)
def setUpClass(cls): cls.working_directory = os.getcwd() os.chdir("vimiv") cls.settings = parse_config() cls.vimiv = v_main.Vimiv(cls.settings, [], 0) cls.vimiv.main()
def setUpClass(cls): cls.initial_directory = os.getcwd() os.chdir("vimiv/testimages") cls.settings = parse_config() cls.vimiv = v_main.Vimiv(cls.settings, [], 0) cls.vimiv.main()
def test_opening_without_path(self): """Opening without an argument.""" vimiv = v_main.Vimiv(self.settings, [], 0) self.assertEqual(vimiv.paths, []) vimiv.main()
def setUpClass(cls): cls.settings = parse_config() cls.vimiv = v_main.Vimiv(cls.settings, [], 0) cls.vimiv.main()