[100] | 1 | import json
|
---|
| 2 | import unittest
|
---|
| 3 |
|
---|
| 4 | from pyson.ObjectMapper import ObjectMapper
|
---|
| 5 |
|
---|
| 6 | from geniusweb.actions.PartyId import PartyId
|
---|
| 7 | from geniusweb.inform.Agreements import Agreements
|
---|
| 8 | from geniusweb.inform.Finished import Finished
|
---|
| 9 | from geniusweb.inform.Inform import Inform
|
---|
| 10 | from geniusweb.issuevalue.Bid import Bid
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | class 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 | |
---|