예제 #1
0
파일: test_process.py 프로젝트: hagna/mold
 def test_ch3(self):
     """
     If ch3 data is received, preppend my name to the list and send it on
     again.
     """
     data = []
     proto = MagicMock()
     p = Channel3Protocol('joe', data.append, proto)
     info = ch3.encode(ch3.fd('jim', 2, 'foo bar'))
     p.childDataReceived(3, '%d:%s,' % (len(info), info))
     self.assertEqual(data[0], ch3.fd('joe.jim', 2, 'foo bar'))
     proto.childDataReceived.assert_called_with(3, '%d:%s,' % (len(info), info))
예제 #2
0
파일: test_process.py 프로젝트: hagna/mold
 def test_writeSequence(self):
     """
     Should log and call through
     """
     self.assertCallTransport('writeSequence', ['foo', 'bar'])
     
     data = []
     t = MagicMock()
     p = Channel3Protocol('joe', data.append, MagicMock())
     p.makeConnection(t)
     p.writeSequence(['foo', 'bar'])
     self.assertEqual(data[0], ch3.fd('joe', 0, 'foo'))
     self.assertEqual(data[1], ch3.fd('joe', 0, 'bar'))
예제 #3
0
파일: test_ch3.py 프로젝트: hagna/mold
 def test_binary(self):
     """
     If there's binary data, encode it.
     """
     m = fd('joe', 2, '\x00\x01\xff')
     self.assertEqual(m, Message('joe', 2, {
         'line': '\x00\x01\xff'.encode('base64'),
         'encoding': 'base64',
     }))
예제 #4
0
파일: test_process.py 프로젝트: hagna/mold
 def test_stdout(self):
     """
     When stdout is received, it should be sent to the channel3 receiver
     """
     data = []
     proto = MagicMock()
     p = Channel3Protocol('joe', data.append, proto)
     p.childDataReceived(1, 'some data')
     self.assertEqual(data[0], ch3.fd('joe', 1, 'some data'))
     proto.childDataReceived.assert_called_with(1, 'some data')
예제 #5
0
파일: test_process.py 프로젝트: hagna/mold
 def test_writeToChild(self):
     """
     Writing to some other channel should be logged and written
     """
     self.assertCallTransport('writeToChild', 22, 'some data')
     
     data = []
     t = MagicMock()
     p = Channel3Protocol('joe', data.append, MagicMock())
     p.makeConnection(t)
     p.writeToChild(22, "some data")
     self.assertEqual(data[0], ch3.fd('joe', 22, 'some data'))
예제 #6
0
파일: test_process.py 프로젝트: hagna/mold
 def test_write(self):
     """
     Writing to stdin should be logged and written
     """
     self.assertCallTransport('write', 'foo bar')
     
     data = []
     t = StringTransport()
     p = Channel3Protocol('joe', data.append, MagicMock())
     p.makeConnection(t)
     p.write('foo bar')
     self.assertEqual(data[0], ch3.fd('joe', 0, 'foo bar'))
     self.assertEqual(t.value(), 'foo bar')
예제 #7
0
파일: test_ch3.py 프로젝트: hagna/mold
 def test_basic(self):
     """
     A stream accepts a name, a file descriptor and some data.
     """
     m = fd('joe', 2, 'data')
     self.assertEqual(m, Message('joe', 2, {'line': 'data'}))
예제 #8
0
파일: process.py 프로젝트: hagna/mold
 def writeSequence(self, seq):
     for x in seq:
         self._ch3_receiver(ch3.fd(self.name, 0, x))
     return self.transport.writeSequence(seq)
예제 #9
0
파일: process.py 프로젝트: hagna/mold
 def writeToChild(self, childFD, data):
     self._ch3_receiver(ch3.fd(self.name, childFD, data))
     return self.transport.writeToChild(childFD, data)
예제 #10
0
파일: process.py 프로젝트: hagna/mold
 def write(self, data):
     """
     Write to stdin
     """
     self._ch3_receiver(ch3.fd(self.name, 0, data))
     return self.transport.write(data)
예제 #11
0
파일: process.py 프로젝트: hagna/mold
 def childDataReceived(self, childfd, data):
     if childfd == 3:
         self._ch3_netstring.dataReceived(data)
     else:
         self._ch3_receiver(ch3.fd(self.name, childfd, data))
     self.sub_proto.childDataReceived(childfd, data)