source: geniuswebcore/test/geniusweb/inform/FinishedTest.py@ 93

Last change on this file since 93 was 90, checked in by Bart Vastenhouw, 3 years ago

Refactor to help reusing partiesserver.

File size: 1.5 KB
Line 
1import json
2import unittest
3
4from pyson.ObjectMapper import ObjectMapper
5
6from geniusweb.actions.PartyId import PartyId
7from geniusweb.inform.Agreements import Agreements
8from geniusweb.inform.Finished import Finished
9from geniusweb.inform.Inform import Inform
10from geniusweb.issuevalue.Bid import Bid
11
12
13class FinishedTest(unittest.TestCase):
14 pyson=ObjectMapper()
15 id1 = PartyId("party1")
16 id2 = PartyId("party2")
17
18 bid1 = Bid({})
19 agrees = Agreements({id1: bid1, id2:bid1 })
20 agrees2 = Agreements({id2: bid1, id2:bid1 })
21
22 finished = Finished(agrees)
23 finished1 = Finished(agrees)
24 finished2 = Finished(agrees2)
25
26 finishedjson:dict={'Finished':{'agreements':{'party1':{'issuevalues':{}},'party2':{'issuevalues':{}}}}}
27
28
29 def testNone(self) :
30 self.assertRaises(ValueError, lambda:Finished(None))
31
32 def testSerialize(self):
33 print(str(self.pyson.toJson(self.finished1)))
34 self.assertEqual(self.finishedjson, self.pyson.toJson(self.finished))
35
36 def testDeserialize(self):
37 self.assertEqual(self.finished, self.pyson.parse(self.finishedjson, Inform))
38
39 def testRepr(self):
40 self.assertEqual("Finished[Agreements{party1=Bid{}, party2=Bid{}}]", repr(self.finished))
41
42 def testEqual(self):
43 self.assertEqual(self.finished, self.finished1)
44 self.assertNotEqual(self.finished, self.finished2)
45 self.assertEqual(hash(self.finished), hash(self.finished1))
46 self.assertNotEqual(hash(self.finished), hash(self.finished2))
47
48
Note: See TracBrowser for help on using the repository browser.