import unittest
from DecisionSystem.messages import Message, deserialise, RequestLeader

class TestMessages(unittest.TestCase):
    def test_base_empty(self):
        self.assertEqual(self.m.sender, "")
        self.assertEqual(self.m.data, {})
        self.assertIsNone(self.m.type)

    def test_base_set(self):
        self.m2.type = "Michael"
        self.assertEqual(self.m2.type, "Michael")
        self.assertEqual(self.m2.data, self.data)
        self.assertEqual(self.m2.sender, 33)

    def test_serialistion(self):
        serialised = self.m2.serialise()
        self.m3 = deserialise(serialised)
        self.assertEqual(self.m2.sender, self.m3.sender)
        self.assertEqual(self.m2.data, self.m3.data)

    def test_RequestLeader(self):
        self.m3 = RequestLeader()
        self.assertEqual(self.m3.type, "RequestLeader")

    def setUp(self):
        self.m = Message()
        self.data = {"hi": 3}
        self.sender = 33
        self.m2 = Message(self.sender,self.data)

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