source: geniuswebcore/test/geniusweb/actions/AcceptTest.py@ 75

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

Fix for IssueValue hashcode.

File size: 1.4 KB
Line 
1from decimal import Decimal
2import unittest
3
4from pyson.ObjectMapper import ObjectMapper
5
6from geniusweb.actions.Accept import Accept
7from geniusweb.actions.Action import Action
8from geniusweb.actions.Offer import Offer
9from geniusweb.actions.PartyId import PartyId
10from geniusweb.issuevalue.Bid import Bid
11from geniusweb.issuevalue.DiscreteValue import DiscreteValue
12from geniusweb.issuevalue.NumberValue import NumberValue
13
14
15class OfferTest (unittest.TestCase) :
16 pyson=ObjectMapper()
17 actor=PartyId("myid")
18 bid=Bid({'fte':NumberValue(Decimal(3)), 'leasecar':DiscreteValue('yes')})
19 bid2=Bid({'fte':NumberValue(Decimal(3)), 'leasecar':DiscreteValue('no')})
20 accept=Accept(actor, bid)
21 accept2=Accept(actor, bid2)
22
23 def testSerialize(self):
24 print(str(self.pyson.toJson(self.accept)))
25 self.assertEqual({'Accept': {'actor': 'myid', 'bid': {'issuevalues':{'fte': 3, 'leasecar': "yes"}}}},\
26 self.pyson.toJson(self.accept))
27
28 def testDeserialize(self):
29 jsonoffer= self.pyson.toJson(self.accept)
30 self.assertEqual(self.accept, self.pyson.parse(jsonoffer, Action))
31
32 def testRepr(self):
33 self.assertEqual('Accept[myid,Bid{fte=3, leasecar="yes"}]', repr(self.accept))
34
35 def testEqual(self):
36 self.assertEqual(self.accept, self.accept)
37 self.assertNotEqual(self.accept, self.accept2)
38 self.assertEqual(hash(self.accept), hash(self.accept))
39 self.assertNotEqual(hash(self.accept), hash(self.accept2))
40
Note: See TracBrowser for help on using the repository browser.