source: geniuswebcore/test/geniusweb/party/CapabilitiesTest.py@ 78

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

Fix for IssueValue hashcode.

File size: 1.9 KB
Line 
1import unittest
2
3from pyson.ObjectMapper import ObjectMapper
4
5from geniusweb.party.Capabilities import Capabilities
6from unitpy.GeneralTests import GeneralTests
7from typing import List
8
9
10class 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
Note: See TracBrowser for help on using the repository browser.