1 | import unittest
|
---|
2 |
|
---|
3 | from pyson.ObjectMapper import ObjectMapper
|
---|
4 |
|
---|
5 | from geniusweb.party.Capabilities import Capabilities
|
---|
6 | from unitpy.GeneralTests import GeneralTests
|
---|
7 | from typing import List
|
---|
8 |
|
---|
9 |
|
---|
10 | class CapabilitiesTest(unittest.TestCase, GeneralTests[Capabilities]):
|
---|
11 | pyson = ObjectMapper()
|
---|
12 |
|
---|
13 | capjson= {"behaviours":["SAOP"], "profiles":["geniusweb.profile.utilityspace.LinearAdditive"]}
|
---|
14 |
|
---|
15 | capabilities1 = Capabilities( set([ "SAOP"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
16 | capabilities1a= Capabilities( set([ "SAOP"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
17 | capabilities2 = Capabilities( set([ "SEB"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
18 | capabilities3 = Capabilities( set([ "SEB", "SAOP"]), set(['geniusweb.profile.utilityspace.LinearAdditive']))
|
---|
19 | capabilities4 = Capabilities( set([ "SAOP"]), set(['geniusweb.profile.PartialOrdering']))
|
---|
20 |
|
---|
21 | def getGeneralTestData(self) -> List[List[Capabilities]]:
|
---|
22 | return [[self.capabilities1, self.capabilities1a], [self.capabilities2], [self.capabilities3], [self.capabilities4]]
|
---|
23 |
|
---|
24 | def getGeneralTestStrings(self) -> List[str]:
|
---|
25 | return ["Capabilities.*geniusweb.profile.utilityspace.LinearAdditive.*SAOP.*",
|
---|
26 | "Capabilities.*geniusweb.profile.utilityspace.LinearAdditive.*SEB.*",
|
---|
27 | "Capabilities.*geniusweb.profile.utilityspace.LinearAdditive.*S.*,.*S.*",
|
---|
28 | "Capabilities.*geniusweb.profile.PartialOrdering.*SAOP.*"]
|
---|
29 |
|
---|
30 | def testSerialize(self):
|
---|
31 | print(str(self.pyson.toJson(self.capabilities1)))
|
---|
32 | self.assertEqual(self.capjson, self.pyson.toJson(self.capabilities1))
|
---|
33 |
|
---|
34 | def testDeserialize(self):
|
---|
35 | self.assertEqual(self.capabilities1, self.pyson.parse(self.capjson, Capabilities))
|
---|
36 |
|
---|
37 | def testbehaviours(self):
|
---|
38 | self.assertEqual(set(["SEB", "SAOP"]), self.capabilities3.getBehaviours())
|
---|
39 |
|
---|