Module connpy.tests.test_completion
Tests for connpy.completion module.
Classes
class TestGetAllFolders-
Expand source code
class TestGetAllFolders: def test_basic_folders(self): config = { "connections": { "office": {"type": "folder"}, "home": {"type": "folder"} } } folders = _getallfolders(config) assert "@office" in folders assert "@home" in folders def test_with_subfolders(self): config = { "connections": { "office": { "type": "folder", "datacenter": {"type": "subfolder"}, "server1": {"type": "connection"} } } } folders = _getallfolders(config) assert "@office" in folders assert "@datacenter@office" in folders def test_empty(self): config = {"connections": {}} folders = _getallfolders(config) assert folders == []Methods
def test_basic_folders(self)-
Expand source code
def test_basic_folders(self): config = { "connections": { "office": {"type": "folder"}, "home": {"type": "folder"} } } folders = _getallfolders(config) assert "@office" in folders assert "@home" in folders def test_empty(self)-
Expand source code
def test_empty(self): config = {"connections": {}} folders = _getallfolders(config) assert folders == [] def test_with_subfolders(self)-
Expand source code
def test_with_subfolders(self): config = { "connections": { "office": { "type": "folder", "datacenter": {"type": "subfolder"}, "server1": {"type": "connection"} } } } folders = _getallfolders(config) assert "@office" in folders assert "@datacenter@office" in folders
class TestGetAllNodes-
Expand source code
class TestGetAllNodes: def test_flat_nodes(self): """Nodes without folders.""" config = { "connections": { "router1": {"type": "connection"}, "router2": {"type": "connection"} } } nodes = _getallnodes(config) assert "router1" in nodes assert "router2" in nodes def test_nested_nodes(self): """Nodes in folders and subfolders have correct format.""" config = { "connections": { "router1": {"type": "connection"}, "office": { "type": "folder", "server1": {"type": "connection"}, "datacenter": { "type": "subfolder", "db1": {"type": "connection"} } } } } nodes = _getallnodes(config) assert "router1" in nodes assert "server1@office" in nodes assert "db1@datacenter@office" in nodes def test_empty_connections(self): config = {"connections": {}} nodes = _getallnodes(config) assert nodes == []Methods
def test_empty_connections(self)-
Expand source code
def test_empty_connections(self): config = {"connections": {}} nodes = _getallnodes(config) assert nodes == [] def test_flat_nodes(self)-
Expand source code
def test_flat_nodes(self): """Nodes without folders.""" config = { "connections": { "router1": {"type": "connection"}, "router2": {"type": "connection"} } } nodes = _getallnodes(config) assert "router1" in nodes assert "router2" in nodesNodes without folders.
def test_nested_nodes(self)-
Expand source code
def test_nested_nodes(self): """Nodes in folders and subfolders have correct format.""" config = { "connections": { "router1": {"type": "connection"}, "office": { "type": "folder", "server1": {"type": "connection"}, "datacenter": { "type": "subfolder", "db1": {"type": "connection"} } } } } nodes = _getallnodes(config) assert "router1" in nodes assert "server1@office" in nodes assert "db1@datacenter@office" in nodesNodes in folders and subfolders have correct format.
class TestGetCwd-
Expand source code
class TestGetCwd: def test_current_dir(self, tmp_path, monkeypatch): """Lists files in current directory.""" monkeypatch.chdir(tmp_path) (tmp_path / "file1.txt").touch() (tmp_path / "file2.py").touch() subdir = tmp_path / "subdir" subdir.mkdir() result = _getcwd(["run", "run"], "run") # Should list files assert any("file1.txt" in r for r in result) assert any("subdir/" in r for r in result) def test_specific_path(self, tmp_path, monkeypatch): """Lists files matching a partial path.""" monkeypatch.chdir(tmp_path) (tmp_path / "script.yaml").touch() (tmp_path / "script2.yaml").touch() result = _getcwd(["run", "script"], "run") assert any("script" in r for r in result) def test_folder_only(self, tmp_path, monkeypatch): """folderonly=True returns only directories.""" monkeypatch.chdir(tmp_path) (tmp_path / "file.txt").touch() subdir = tmp_path / "mydir" subdir.mkdir() result = _getcwd(["export", "export"], "export", folderonly=True) files_in_result = [r for r in result if "file.txt" in r] assert len(files_in_result) == 0 dirs_in_result = [r for r in result if "mydir" in r] assert len(dirs_in_result) > 0Methods
def test_current_dir(self, tmp_path, monkeypatch)-
Expand source code
def test_current_dir(self, tmp_path, monkeypatch): """Lists files in current directory.""" monkeypatch.chdir(tmp_path) (tmp_path / "file1.txt").touch() (tmp_path / "file2.py").touch() subdir = tmp_path / "subdir" subdir.mkdir() result = _getcwd(["run", "run"], "run") # Should list files assert any("file1.txt" in r for r in result) assert any("subdir/" in r for r in result)Lists files in current directory.
def test_folder_only(self, tmp_path, monkeypatch)-
Expand source code
def test_folder_only(self, tmp_path, monkeypatch): """folderonly=True returns only directories.""" monkeypatch.chdir(tmp_path) (tmp_path / "file.txt").touch() subdir = tmp_path / "mydir" subdir.mkdir() result = _getcwd(["export", "export"], "export", folderonly=True) files_in_result = [r for r in result if "file.txt" in r] assert len(files_in_result) == 0 dirs_in_result = [r for r in result if "mydir" in r] assert len(dirs_in_result) > 0folderonly=True returns only directories.
def test_specific_path(self, tmp_path, monkeypatch)-
Expand source code
def test_specific_path(self, tmp_path, monkeypatch): """Lists files matching a partial path.""" monkeypatch.chdir(tmp_path) (tmp_path / "script.yaml").touch() (tmp_path / "script2.yaml").touch() result = _getcwd(["run", "script"], "run") assert any("script" in r for r in result)Lists files matching a partial path.
class TestGetPlugins-
Expand source code
class TestGetPlugins: def test_get_plugins_disable(self, tmp_path): """--disable returns enabled plugins.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "active.py").touch() (plugin_dir / "disabled.py.bkp").touch() result = _get_plugins("--disable", str(tmp_path)) assert "active" in result assert "disabled" not in result def test_get_plugins_enable(self, tmp_path): """--enable returns disabled plugins.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "active.py").touch() (plugin_dir / "disabled.py.bkp").touch() result = _get_plugins("--enable", str(tmp_path)) assert "disabled" in result assert "active" not in result def test_get_plugins_del(self, tmp_path): """--del returns all plugins.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "active.py").touch() (plugin_dir / "disabled.py.bkp").touch() result = _get_plugins("--del", str(tmp_path)) assert "active" in result assert "disabled" in result def test_get_plugins_all(self, tmp_path): """'all' returns dict with paths.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "myplugin.py").touch() result = _get_plugins("all", str(tmp_path)) assert isinstance(result, dict) assert "myplugin" in result def test_get_plugins_empty_dir(self, tmp_path): """Empty plugins directory returns empty list.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() result = _get_plugins("--disable", str(tmp_path)) assert result == []Methods
def test_get_plugins_all(self, tmp_path)-
Expand source code
def test_get_plugins_all(self, tmp_path): """'all' returns dict with paths.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "myplugin.py").touch() result = _get_plugins("all", str(tmp_path)) assert isinstance(result, dict) assert "myplugin" in result'all' returns dict with paths.
def test_get_plugins_del(self, tmp_path)-
Expand source code
def test_get_plugins_del(self, tmp_path): """--del returns all plugins.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "active.py").touch() (plugin_dir / "disabled.py.bkp").touch() result = _get_plugins("--del", str(tmp_path)) assert "active" in result assert "disabled" in result–del returns all plugins.
def test_get_plugins_disable(self, tmp_path)-
Expand source code
def test_get_plugins_disable(self, tmp_path): """--disable returns enabled plugins.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "active.py").touch() (plugin_dir / "disabled.py.bkp").touch() result = _get_plugins("--disable", str(tmp_path)) assert "active" in result assert "disabled" not in result–disable returns enabled plugins.
def test_get_plugins_empty_dir(self, tmp_path)-
Expand source code
def test_get_plugins_empty_dir(self, tmp_path): """Empty plugins directory returns empty list.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() result = _get_plugins("--disable", str(tmp_path)) assert result == []Empty plugins directory returns empty list.
def test_get_plugins_enable(self, tmp_path)-
Expand source code
def test_get_plugins_enable(self, tmp_path): """--enable returns disabled plugins.""" plugin_dir = tmp_path / "plugins" plugin_dir.mkdir() (plugin_dir / "active.py").touch() (plugin_dir / "disabled.py.bkp").touch() result = _get_plugins("--enable", str(tmp_path)) assert "disabled" in result assert "active" not in result–enable returns disabled plugins.