コード例 #1
0
 def __test_send_raises(self, type, payload, expected_exception):
     socket = FakeWritableSocket()
     with self.assertRaises(expected_exception):
         m2proto.send(socket, type, payload)
     self.assertEqual(socket.fake_data(), b'')
コード例 #2
0
 def __test_send(self, type, payload, expected_data):
     socket = FakeWritableSocket()
     self.assertTrue(m2proto.send(socket, type, payload))
     self.assertEqual(socket.fake_data(), expected_data)
コード例 #3
0
 def test_send_empty(self):
     socket = FakeWritableSocket()
     self.assertTrue(m1proto.send(socket, ''))
     self.assertEqual(socket.fake_data(), b'\0')
コード例 #4
0
 def test_send_too_big(self):
     socket = FakeWritableSocket()
     with self.assertRaises(m1proto.PayloadTooBig):
         m1proto.send(socket, 'x' * 256)
     self.assertEqual(socket.fake_data(), b'')
コード例 #5
0
 def test_send_max(self):
     socket = FakeWritableSocket()
     self.assertTrue(m1proto.send(socket, 'x' * 255))
     self.assertEqual(socket.fake_data(), b'\xFF' + (b'x' * 255))
コード例 #6
0
 def test_send_unicode(self):
     socket = FakeWritableSocket()
     self.assertTrue(m1proto.send(socket, '\xA0'))
     self.assertEqual(socket.fake_data(), b'\x02\xC2\xA0')
コード例 #7
0
 def test_send_ascii(self):
     socket = FakeWritableSocket()
     self.assertTrue(m1proto.send(socket, 'abc'))
     self.assertEqual(socket.fake_data(), b'\x03abc')