def GET(self, host=None, path=None): if host is None or path is None: logging.warning( 'API: Either host or path are missing, nothing returned') return PathTransformer.paths([]) try: ssh = Ssh() contents = ssh.get_contents(host, path) sorted_contents = sorted( contents, key=lambda x: x['type'] + ':' + x['name'].lower(), reverse=False) return PathTransformer.paths(sorted_contents) except PathNotFoundException as e: logging.warning('API: Path {} not found, nearest path {}'.format( path, e.nearest_path)) return PathTransformer.nearest_path(e.nearest_path)
def test_ssh_uses_remotehost_directory_iteration(self, mock_method): mock_method.return_value = "remote" ssh = Ssh() assert ssh.get_contents('remotehost', '/') == "remote"