1 | import unittest
|
---|
2 |
|
---|
3 | from pyson.ObjectMapper import ObjectMapper
|
---|
4 |
|
---|
5 | from geniusweb.party.Capabilities import Capabilities
|
---|
6 |
|
---|
7 |
|
---|
8 | class PartyTest(unittest.TestCase):
|
---|
9 | pyson = ObjectMapper()
|
---|
10 | cap= Capabilities( set([ "SAOP"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
11 | cap1= Capabilities( set([ "SAOP"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
12 | cap2= Capabilities( set([ "SHAOP"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
13 | cap3= Capabilities( set([ "SAOP"]), set(['geniusweb.profile.Profile']))
|
---|
14 | capjson= {"behaviours":["SAOP"], "profiles":["geniusweb.profile.utilityspace.LinearAdditive"]}
|
---|
15 |
|
---|
16 | def testSerialize(self):
|
---|
17 | print(str(self.pyson.toJson(self.cap)))
|
---|
18 | self.assertEqual(self.capjson, self.pyson.toJson(self.cap))
|
---|
19 |
|
---|
20 | def testDeserialize(self):
|
---|
21 | self.assertEqual(self.cap, self.pyson.parse(self.capjson, Capabilities))
|
---|
22 |
|
---|
23 | def testRepr(self):
|
---|
24 | self.assertEqual("Capabilities[{'geniusweb.profile.utilityspace.LinearAdditive'},{'SAOP'}]", repr(self.cap))
|
---|
25 |
|
---|
26 | def testEqual(self):
|
---|
27 | self.assertEqual(self.cap, self.cap1)
|
---|
28 | self.assertNotEqual(self.cap, self.cap2)
|
---|
29 | self.assertNotEqual(self.cap, self.cap3)
|
---|
30 | self.assertEqual(hash(self.cap), hash(self.cap1))
|
---|
31 | self.assertNotEqual(hash(self.cap), hash(self.cap2))
|
---|
32 | self.assertNotEqual(hash(self.cap), hash(self.cap3))
|
---|
33 | |
---|