예제 #1
0
 def __init__(
     self, base_dirs: List[str], root_markers: List[str] = [".git"], eager_mode=False
 ) -> None:
     """Constructor of TmuxDirFacade."""
     TmuxSessionFacade.__init__(self)
     DirMngr.__init__(
         self, base_dirs=base_dirs, root_markers=root_markers, eager_mode=eager_mode
     )
예제 #2
0
def dir_mngr() -> DirMngr:
    folder_name = "/tmp/tmuxdirtest/"
    os.makedirs(folder_name, exist_ok=True)
    cfg_handler = ConfigHandler(folder_name=folder_name)
    yield DirMngr([], [".git"], cfg_handler=cfg_handler)
    try:
        os.remove(str(cfg_handler._full_path))
    except FileNotFoundError:
        pass
    os.removedirs(folder_name)
예제 #3
0
    def __init__(self, vim: vim.Nvim) -> None:
        """Constructor of TmuxDirPlugin."""
        self.vim = vim
        self.plugin_name = "tmuxdir"

        # vim settings
        self.root_markers: List[str] = self.vim.eval("TmuxdirRootMarkers()")
        self.base_dirs: List[str] = self.vim.eval("TmuxdirBaseDirs()")

        self.dir_mngr = DirMngr(
            base_dirs=self.base_dirs, root_markers=self.root_markers
        )

        self.tmux_dir = TmuxDirFacade(self.base_dirs, self.root_markers)
        try:
            self.tmux_dir._check_tmux_bin()
        except TmuxFacadeException as e:
            echoerr(self.vim, str(e), self.plugin_name)
예제 #4
0
 def test_clear_ignored_dirs(self, dir_mngr: DirMngr, tmp_git_folder: str):
     assert dir_mngr.add(tmp_git_folder)[0] == tmp_git_folder
     assert dir_mngr.ignore(tmp_git_folder)
     assert dir_mngr.clear_ignored_dirs()
     assert dir_mngr.ignored_dirs == {}
     assert dir_mngr.cfg_handler.load()[dir_mngr._IGNORED_DIRS_KEY] == {}
예제 #5
0
 def test_add_ignore(self, dir_mngr: DirMngr, tmp_git_folder: str):
     assert dir_mngr.add(tmp_git_folder) == [tmp_git_folder]
     assert dir_mngr.ignore(tmp_git_folder)
     assert dir_mngr.add(tmp_git_folder) == []
     assert tmp_git_folder not in dir_mngr.list_dirs()
예제 #6
0
 def test_clear_added_dirs(self, dir_mngr: DirMngr, tmp_git_folder: str):
     assert dir_mngr.add(tmp_git_folder)[0] == tmp_git_folder
     assert dir_mngr.clear_added_dir(tmp_git_folder)
     assert dir_mngr.dirs == {}
     assert dir_mngr.cfg_handler.load()[dir_mngr._DIRS_KEY] == {}
예제 #7
0
 def test_add_clear(self, dir_mngr: DirMngr, tmp_git_folder: str):
     assert dir_mngr.add(tmp_git_folder) == [tmp_git_folder]
     assert dir_mngr.clear_added_dir(tmp_git_folder)
     assert dir_mngr.list_dirs() == []
     assert not dir_mngr.clear_added_dir("/tmp/random/")
     assert tmp_git_folder not in dir_mngr.dirs
예제 #8
0
 def test_add_dir_list(self, dir_mngr: DirMngr, tmp_git_folder: str):
     folder = "/tmp/pit/"
     assert dir_mngr.add(folder) == []
예제 #9
0
 def test_add_dir(self, dir_mngr: DirMngr, tmp_git_folder: str):
     assert dir_mngr.add(tmp_git_folder)[0] == tmp_git_folder
     assert dir_mngr.add("/tmp/foo") == []
     assert tmp_git_folder in dir_mngr.dirs