def send_stream(self, action): """Send a text stream representing the action.""" data = TextStream.make_stream(action) log.debug(u"TO PEER: %s" % data) size = 0 while size < len(data): data = data[size:] size = self.socket.send(data) return size
def testAcceptAction(self): expected = u'P2P 1 2 john' action = AcceptStartAction(name="john") stream = TextStream.make_stream(action) self.assertEqual(expected.lower(), stream.lower())
def testStartAction(self): expected = u'P2P 1 1 ' action = StartAction() stream = TextStream.make_stream(action) self.assertEqual(expected.lower(), stream.lower())