[59] | 1 | import unittest
|
---|
| 2 |
|
---|
| 3 | from pyson.ObjectMapper import ObjectMapper
|
---|
| 4 |
|
---|
| 5 | from geniusweb.actions.EndNegotiation import EndNegotiation
|
---|
| 6 | from geniusweb.actions.PartyId import PartyId
|
---|
| 7 | from geniusweb.inform.ActionDone import ActionDone
|
---|
| 8 | from geniusweb.inform.Inform import Inform
|
---|
| 9 | from geniusweb.inform.YourTurn import YourTurn
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | class ActionDoneTest(unittest.TestCase):
|
---|
| 13 |
|
---|
| 14 | pyson=ObjectMapper()
|
---|
| 15 | pid1=PartyId("party1")
|
---|
| 16 | pid2=PartyId("party2")
|
---|
| 17 |
|
---|
| 18 | endnego=EndNegotiation(pid1)
|
---|
| 19 | endnego1=EndNegotiation(pid1)
|
---|
| 20 | endnego2=EndNegotiation(pid2)
|
---|
| 21 |
|
---|
| 22 | actiondone=ActionDone(endnego)
|
---|
| 23 | actiondone1=ActionDone(endnego1)
|
---|
| 24 | actiondone2=ActionDone(endnego2)
|
---|
| 25 |
|
---|
| 26 | actiondonejson = {"ActionDone":{"action":{"EndNegotiation":{"actor":"party1"}}}}
|
---|
| 27 |
|
---|
| 28 | def testSerializeDeserialize(self):
|
---|
| 29 |
|
---|
| 30 | print(str(self.pyson.toJson(self.actiondone)))
|
---|
| 31 | self.assertEqual(self.actiondonejson, self.pyson.toJson(self.actiondone))
|
---|
| 32 |
|
---|
| 33 | def testDeserialize(self):
|
---|
| 34 | self.assertEqual(self.actiondone, self.pyson.parse(self.actiondonejson, Inform))
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | def testRepr(self):
|
---|
| 38 | self.assertEqual("ActionDone[EndNegotiation[party1]]", repr(self.actiondone))
|
---|
| 39 |
|
---|
| 40 | def testEqual(self):
|
---|
| 41 | self.assertEqual(self.actiondone, self.actiondone1)
|
---|
| 42 | self.assertNotEqual(self.actiondone, self.actiondone2)
|
---|
| 43 | self.assertEqual(hash(self.actiondone), hash(self.actiondone1))
|
---|
| 44 | self.assertNotEqual(hash(self.actiondone), hash(self.actiondone2))
|
---|
| 45 |
|
---|
| 46 | |
---|