Esempio n. 1
0
 def test_open(self, flush_mock, ssh_mock):
     channel = ssh_mock.return_value.get_shell.return_value
     channel.recv_ready.side_effect= [True, False]   # 1st for actual data
     channel.recv.return_value = ("xyz\r\n"+'(END)'+PlugLess.OPEN[1][0])
     pl = PlugLess(path='path', cols=5, rows=5)
     pl.put_request(PlugLess.OPEN)
     
     self.assertTrue(pl.check_response())
     channel.send.assert_called_with('less path\n')
     self.assertTrue(pl.launched)
     # call again without data available
     self.assertTrue(pl.check_response())
Esempio n. 2
0
    def test_not_found(self, flush_mock, ssh_mock):
        channel = ssh_mock.return_value.get_shell.return_value
        channel.recv_ready.return_value = [True]
        channel.recv.return_value = ("aaa: No such file or directory\r\n")
        pl = PlugLess(path='path', cols=5, rows=5)
        pl.put_request(PlugLess.OPEN)

        self.assertTrue(pl.check_response())
        self.assertFalse(pl.launched)
        channel.send.assert_called_with('less path\n')