source: geniuswebcore/test/geniusweb/actions/PartyIdTest.py@ 77

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

Fix for IssueValue hashcode.

File size: 1.4 KB
Line 
1import unittest
2
3from pyson.ObjectMapper import ObjectMapper
4
5from geniusweb.actions.PartyId import PartyId
6
7
8#FIXME support and test serialization
9class PartyIdTest (unittest.TestCase) :
10
11 pyson=ObjectMapper()
12 party=PartyId("a")
13 party1=PartyId("a")
14 party2=PartyId("b")
15
16
17 def testRestrictions(self):
18 self.assertRaises(ValueError, lambda : PartyId(""))
19
20 def testRestrictions2(self):
21 self.assertRaises(ValueError, lambda:PartyId("@2"))
22
23 def testRestrictions3(self) :
24 self.assertRaises(ValueError, lambda:PartyId("_12"))
25
26
27 def testRestrictions4(self):
28 self.assertRaises(ValueError, lambda :PartyId("12A"))
29
30 def testRestrictions5(self):
31 self.assertRaises(ValueError,lambda :PartyId(" fds "))
32
33 def testRestrictions6(self):
34 PartyId("A_1_23_ok")
35
36 def testRestrictions7(self):
37 PartyId("a_1_23_ok")
38
39 def testGetName(self):
40 self.assertEqual("a", self.party1.getName());
41
42
43 def testSerialize(self):
44 print(str(self.pyson.toJson(self.party1)))
45 self.assertEqual("a",self.pyson.toJson(self.party))
46
47 def testDeserialize(self):
48 self.assertEqual(self.party, self.pyson.parse("a", PartyId))
49
50
51 def testRepr(self):
52 self.assertEqual("a", repr(self.party))
53
54 def testEqual(self):
55 self.assertEqual(self.party, self.party1)
56 self.assertNotEqual(self.party1, self.party2)
57 self.assertEqual(hash(self.party), hash(self.party1))
58 self.assertNotEqual(hash(self.party), hash(self.party2))
59
Note: See TracBrowser for help on using the repository browser.