def test_path_startswith_tilda_cmdfail(self): class MockSSHShell2(MockSSHShell): def run(self, cmd): result = False stdout = "" return result, stdout scget = SplitCopyGet() scget.sshshell = MockSSHShell2() scget.remote_dir = "~foo/bar" with raises(ValueError): scget.path_startswith_tilda()
def test_path_startswith_tilda(self): class MockSSHShell2(MockSSHShell): def run(self, cmd): result = True stdout = "foo@bar:~$ ls -d ~/bar\n" "/homes/foo/bar\n" "foo@bar:~$" return result, stdout scget = SplitCopyGet() scget.sshshell = MockSSHShell2() scget.remote_dir = "~foo/bar" scget.remote_file = "test" scget.path_startswith_tilda() assert (scget.remote_dir == "/homes/foo/bar" and scget.remote_path == "/homes/foo/bar/test")