def test_message_len(self): # Test the overriden len function # First case is when the msg has no data, creates data msg = Message({'__SIGNATURE__': "Test"}) length = len(dict2cbor(msg.dump())) self.assertIsNone(msg._data) self.assertEqual(len(msg), length) # The second case is when the msg does have data msg2 = Message({"__SIGNATURE__": "Test"}) msg2._data = "test data" self.assertEqual(len(msg2), len("test data"))
def test_message_len(self): # Test the overriden len function # First case is when the msg has no data, creates data msg = Message({'__SIGNATURE__': "Test"}) length = len(dict2cbor(msg.dump())) self.assertIsNone(msg._data) self.assertEquals(len(msg), length) # The second case is when the msg does have data msg2 = Message({"__SIGNATURE__": "Test"}) msg2._data = "test data" self.assertEquals(len(msg2), len("test data"))
def test_message_repr(self): # Test the overridden repr function # First case to test is when the msg has no data, creates data msg = Message({'__SIGNATURE__': "Test"}) serMsg = msg.serialize() self.assertIsNone(msg._data) self.assertEqual(repr(msg), serMsg) self.assertEqual(msg._data, serMsg) # Second case is when the msg contains data msg2 = Message({'__SIGNATURE__': "Test"}) msg2._data = "test data" self.assertEqual(repr(msg2), "test data") self.assertEqual(msg2._data, "test data")
def test_message_repr(self): # Test the overridden repr function # First case to test is when the msg has no data, creates data msg = Message({'__SIGNATURE__': "Test"}) serMsg = msg.serialize() self.assertIsNone(msg._data) self.assertEquals(repr(msg), serMsg) self.assertEquals(msg._data, serMsg) # Second case is when the msg contains data msg2 = Message({'__SIGNATURE__': "Test"}) msg2._data = "test data" self.assertEquals(repr(msg2), "test data") self.assertEquals(msg2._data, "test data")