Example #1
0
 def test_equality(self):
     m1 = PongMessage()
     m2 = PongMessage()
     m3 = PongMessage(id='m3')
     m4 = PongMessage(id='m4')
     self.assertEqual(m1, m1)
     self.assertEqual(m1, m2)
     self.assertEqual(m3, m3)
     self.assertNotEqual(m1, m3)
     self.assertNotEqual(m3, m4)
     self.assertNotEqual(m1, object())
     self.assertNotEqual(m3, object())
 def test_without_id(self):
     pod = self.serializer.serialize(PongMessage())
     self.assertEqual(pod, {'msg': 'pong'})
 def test_with_id(self):
     id = 'test'
     pod = self.serializer.serialize(PongMessage(id=id))
     self.assertEqual(pod, {'msg': 'pong', 'id': id})
Example #4
0
 def test_without_id(self):
     message = PongMessage()
     self.assertFalse(message.has_id())
     self.assertIsNone(message.id)
Example #5
0
 def test_with_id(self):
     id = 'test'
     message = PongMessage(id=id)
     self.assertTrue(message.has_id())
     self.assertEqual(message.id, id)
Example #6
0
 def test_str(self):
     m1 = PongMessage()
     m2 = PongMessage(id='m2')
     self.assertEqual(eval(str(m1)), m1)
     self.assertEqual(eval(str(m2)), m2)
Example #7
0
 def _on_ping(self, topic, message):
     self._board.publish(MessageSendPong, PongMessage(id=message.id))
 def test_without_id(self):
     message = self.parser.parse({'msg': 'pong'})
     self.assertEqual(message, PongMessage())
 def test_with_id(self):
     id = 'test'
     message = self.parser.parse({'msg': 'pong', 'id': id})
     self.assertEqual(message, PongMessage(id=id))