source: geniuswebcore/test/geniusweb/references/PartyWithProfileTest.py@ 100

Last change on this file since 100 was 100, checked in by ruud, 14 months ago

python installs also wheel to avoid error messages

File size: 2.4 KB
Line 
1import json
2from typing import List
3import unittest
4
5from pyson.ObjectMapper import ObjectMapper
6from unitpy.GeneralTests import GeneralTests
7from uri.uri import URI
8
9from geniusweb.references.Parameters import Parameters
10from geniusweb.references.PartyRef import PartyRef
11from geniusweb.references.PartyWithParameters import PartyWithParameters
12from geniusweb.references.PartyWithProfile import PartyWithProfile
13from geniusweb.references.ProfileRef import ProfileRef
14
15
16class PartyWithProfileTest (unittest.TestCase, GeneralTests[PartyWithProfile]):
17
18 serialized = "{\"party\":{\"partyref\":\"ws:party1\",\"parameters\":{}},\"profile\":\"ws:profile1\"}"
19
20 party1 = PartyRef(URI("ws:party1"))
21 party1a = PartyRef( URI("ws:party1"))
22 party2 = PartyRef( URI("ws:party2"))
23 party3 = PartyRef( URI("http:party3"))
24
25 profile1 = ProfileRef(URI("ws:profile1"))
26 profile2 = ProfileRef( URI("ws:profile2"))
27
28 settings1 = Parameters()
29 settings2 = Parameters({"a": 1})
30
31 party1withparams1 = PartyWithParameters(party1,settings1)
32 party1withparams2 = PartyWithParameters(party1,settings2)
33 party2withparams1 = PartyWithParameters(party2,settings1)
34
35 partyprof1 = PartyWithProfile(party1withparams1, profile1)
36 partyprof1a = PartyWithProfile(party1withparams1, profile1)
37 partyprof2 = PartyWithProfile(party2withparams1, profile1)
38 partyprof3 = PartyWithProfile(party1withparams1, profile2)
39 partyprof4 = PartyWithProfile(party1withparams2, profile1)
40
41
42 def getGeneralTestData(self) -> List[List[PartyWithProfile]] :
43 return [[self.partyprof1, self.partyprof1a], [self.partyprof2],[self.partyprof3],
44 [self.partyprof4]]
45
46 def getGeneralTestStrings(self) -> List[str] :
47 return [
48 "PartyWithProfile.PartyRef.ws:party1.,ProfileRef.ws:profile1.*",
49 "PartyWithProfile.PartyRef.ws:party2.,ProfileRef.ws:profile1.*",
50 "PartyWithProfile.PartyRef.ws:party1.,ProfileRef.ws:profile2.*",
51 "PartyWithProfile.PartyRef.ws:party1.{a=1},ProfileRef.ws:profile1.*"]
52
53 def testSmoke(self) :
54 pass
55
56 def testNull(self) :
57 self.assertRaises(ValueError, lambda:PartyWithProfile(None, None))
58
59 def testSerialize(self) :
60 jackson = ObjectMapper()
61
62 jsonobj = jackson.toJson(self.partyprof1);
63 print(str(jsonobj))
64 self.assertEqual(json.loads(self.serialized), jsonobj);
65
66 def testDeserialize(self):
67 jackson = ObjectMapper()
68 p = jackson.parse(json.loads(self.serialized), PartyWithProfile)
69 print(str(p))
70 self.assertEqual(self.partyprof1, p)
Note: See TracBrowser for help on using the repository browser.