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