source: geniuswebcore/test/geniusweb/inform/ActionDoneTest.py@ 59

Last change on this file since 59 was 59, checked in by Wouter Pasman, 3 years ago

#44 manual commit of first public release, because this will cause the dist directory to move

File size: 1.5 KB
Line 
1import unittest
2
3from pyson.ObjectMapper import ObjectMapper
4
5from geniusweb.actions.EndNegotiation import EndNegotiation
6from geniusweb.actions.PartyId import PartyId
7from geniusweb.inform.ActionDone import ActionDone
8from geniusweb.inform.Inform import Inform
9from geniusweb.inform.YourTurn import YourTurn
10
11
12class 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
Note: See TracBrowser for help on using the repository browser.