Beispiel #1
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')
Beispiel #2
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())
Beispiel #3
0
 def _log_open(self, **kwargs):
     conn_id = kwargs['conn_id']
     conn = self._touch_conn(conn_id)
     kwargs['ssh'] = conn
     log = PlugLess(**kwargs)
     
     log_id = str(uuid.uuid4())
     log.__log_id = log_id
     self._log_sessions[log_id] = [log, self.PL_ACTIVE, kwargs['cmd'], conn_id]
     self._sock_read_fd.append(log)
     logger.info(self.name+'New log was registered, log_id = %s' % log_id)
     log.put_request(PlugLess.OPEN)