def test_parse_dirs(self): """Check if all directories where created correctly.""" vimivdir = os.path.join(os.path.expanduser('~'), ".vimiv") parser.parse_dirs(vimivdir) trashdir = os.path.join(vimivdir, "Trash") tagdir = os.path.join(vimivdir, "Tags") thumbdir = os.path.join(vimivdir, "Thumbnails") for directory in [vimivdir, trashdir, tagdir, thumbdir]: self.assertTrue(os.path.isdir(directory))
def setUpClass(cls): cls.compare_result = False # Used for the clipboard comparison cls.test_directory = os.path.abspath("vimiv/") cls.init_test(cls, [cls.test_directory]) # Run in a temporary directory to leave alone the user's Trash and # Thumbnails options = GLib.VariantDict() bool_true = GLib.Variant("b", True) options.insert_value("temp-basedir", bool_true) cls.vimiv.do_handle_local_options(options) parse_dirs(cls.vimiv.directory) cls.vimiv.init_widgets() cls.vimiv.activate_vimiv(cls.vimiv) cls.trashdir = os.path.join(cls.vimiv.directory, "Trash") cls.thumbdir = os.path.join(cls.vimiv.directory, "Thumbnails")
def setUpClass(cls): cls.compare_result = False # Used for the clipboard comparison cls.test_directory = os.path.abspath("vimiv/") cls.init_test(cls, [cls.test_directory]) # Run in a temporary directory to leave alone the user's Trash and # Thumbnails options = GLib.VariantDict.new() bool_true = GLib.Variant("b", True) options.insert_value("temp-basedir", bool_true) cls.vimiv.do_handle_local_options(options) parse_dirs(cls.vimiv.directory) cls.vimiv.init_widgets() cls.vimiv.activate_vimiv(cls.vimiv) cls.trashdir = os.path.join(cls.vimiv.directory, "Trash") cls.thumbdir = os.path.join(cls.vimiv.directory, "Thumbnails")
def test_temp_basedir(self): """Using a temporary basedir.""" options = GLib.VariantDict.new() bool_true = GLib.Variant("b", True) options.insert_value("temp-basedir", bool_true) self.vimiv.do_handle_local_options(options) # Directory should be in tmp self.assertIn("/tmp/", self.vimiv.directory) self.tmpdir = self.vimiv.directory # Reinitialize the widgets with the new base directory parse_dirs(self.vimiv.directory) self.vimiv.init_widgets() # Thumbnail, Tag and Trash directory should contain tmp self.assertIn("/tmp/", self.vimiv["thumbnail"].directory) self.assertIn("/tmp/", self.vimiv["tags"].directory) self.assertIn("/tmp/", self.vimiv["image"].trashdir) # Create a tag in tmp as a simple test self.vimiv["tags"].write(["image1.py", "image2.py"], "tmptag") tagdir = os.path.join(self.vimiv.directory, "Tags") self.assertIn("tmptag", os.listdir(tagdir))
def test_temp_basedir(self): """Using a temporary basedir.""" options = GLib.VariantDict() bool_true = GLib.Variant("b", True) options.insert_value("temp-basedir", bool_true) self.vimiv.do_handle_local_options(options) # Directory should be in tmp self.assertIn("/tmp/", self.vimiv.directory) self.tmpdir = self.vimiv.directory # Reinitialize the widgets with the new base directory parse_dirs(self.vimiv.directory) self.vimiv.init_widgets() # Thumbnail, Tag and Trash directory should contain tmp self.assertIn("/tmp/", self.vimiv["thumbnail"].directory) self.assertIn("/tmp/", self.vimiv["tags"].directory) self.assertIn("/tmp/", self.vimiv["image"].trashdir) # Create a tag in tmp as a simple test self.vimiv["tags"].write(["image1.py", "image2.py"], "tmptag") tagdir = os.path.join(self.vimiv.directory, "Tags") self.assertIn("tmptag", os.listdir(tagdir))
def activate_vimiv(self, app): """Starting point for the vimiv application. Args: app: The application itself. """ parse_dirs(self.directory) self.init_widgets() self.create_window_structure() app.add_window(self["window"]) # Show everything and then hide whatever needs to be hidden self["window"].show_all() self["manipulate"].scrolled_win.hide() self["commandline"].entry.hide() self["completions"].hide() # Statusbar depending on setting if self["statusbar"].hidden: self["statusbar"].bar.hide() self["statusbar"].set_separator_height() # Try to generate imagelist recursively from the current directory if # recursive is given and not paths exist if self.settings["GENERAL"]["recursive"] and not self.paths: shuffle = self.settings["GENERAL"]["shuffle"] self.paths, self.index = populate([os.getcwd()], True, shuffle) # Show the image if an imagelist exists if self.paths: self["image"].load_image() # Show library at the beginning? if not self["library"].show_at_start: self["library"].grid.hide() self["image"].scrolled_win.grab_focus() # Start in slideshow mode? if self["slideshow"].at_start: self["slideshow"].toggle() else: # Slideshow without paths makes no sense self["slideshow"].running = False self["library"].reload(os.getcwd()) if self["library"].expand: self["image"].scrolled_win.hide() self["statusbar"].err_message("No valid paths, opening library viewer")