import unittest from pyson.ObjectMapper import ObjectMapper from geniusweb.actions.EndNegotiation import EndNegotiation from geniusweb.actions.PartyId import PartyId from geniusweb.inform.ActionDone import ActionDone from geniusweb.inform.Inform import Inform from geniusweb.inform.YourTurn import YourTurn class ActionDoneTest(unittest.TestCase): pyson=ObjectMapper() pid1=PartyId("party1") pid2=PartyId("party2") endnego=EndNegotiation(pid1) endnego1=EndNegotiation(pid1) endnego2=EndNegotiation(pid2) actiondone=ActionDone(endnego) actiondone1=ActionDone(endnego1) actiondone2=ActionDone(endnego2) actiondonejson = {"ActionDone":{"action":{"EndNegotiation":{"actor":"party1"}}}} def testSerializeDeserialize(self): print(str(self.pyson.toJson(self.actiondone))) self.assertEqual(self.actiondonejson, self.pyson.toJson(self.actiondone)) def testDeserialize(self): self.assertEqual(self.actiondone, self.pyson.parse(self.actiondonejson, Inform)) def testRepr(self): self.assertEqual("ActionDone[EndNegotiation[party1]]", repr(self.actiondone)) def testEqual(self): self.assertEqual(self.actiondone, self.actiondone1) self.assertNotEqual(self.actiondone, self.actiondone2) self.assertEqual(hash(self.actiondone), hash(self.actiondone1)) self.assertNotEqual(hash(self.actiondone), hash(self.actiondone2))