import unittest
import json
from Message import Message

# assertEquals(a, b, msg=None) a == b
# assertNotEqual(a, b, msg=None) a != b
# assertTrue(x) bool(x) is True
# assertFalse(x) bool(x) is False
# assertIs(a, b) a is b
# assertIsNot(a, b) a is not b
# assertIsNone(x) x is None
# assertIsNotNone(x) x is not None
# assertIn(a, b) a in b
# assertNotIn(a, b) a not in b
# assertIsInstance(a, b) isinstance(a, b)
# assertNotIsInstance(a, b) not isinstance(a, b)
# assertRaises

#This simulates sending a message. Note the absense of a checksum and uuid - this is autogenerated at the creation of the Message object
sendMessage = Message('car10393','ccs','mls', 100, 'payload: This message format defined by subteams')
communication = sendMessage.ConvertToJSON()
#print(communication)

#This simulates recieving a message. Note the call to check the message checksum after it has been converted to an object
receivedMessage = sendMessage.ConvertFromJSON(communication)

#subclass 
class MyTest(unittest.TestCase):
    def setUp(self):
        pass

    def testChecksum(self):
        self.assertEqual(receivedMessage.CompareChecksum(), True )
        
    def testPayload(self):
        self.assertEqual(receivedMessage.Return_Payload(), 'payload: This message format defined by subteams')
        
    def testOriginID(self):
        self.assertEqual(receivedMessage.Return_Origin_ID(), 'ccs')

if __name__ == '__main__':
    unittest.main()

