source: geniuswebcore/test/geniusweb/references/PartiWithParamsTest.py

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

python installs also wheel to avoid error messages

File size: 1.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
12
13
14class PartiWithParamsTest (unittest.TestCase, GeneralTests[PartyWithParameters]):
15 serialized = "{\"partyref\":\"ws:party1\",\"parameters\":{\"a\":1}}";
16
17 party1 = PartyRef( URI("ws:party1"))
18 party2 = PartyRef( URI("ws:party2"))
19 param1 = Parameters()
20 param2 = Parameters().With("a", 1)
21 party1param1 = PartyWithParameters(party1, param1)
22 party1param1a = PartyWithParameters(party1, param1)
23 party1param2 = PartyWithParameters(party1, param2)
24
25 def getGeneralTestData(self)->List[List[PartyWithParameters]]:
26 return [[ self.party1param1, self.party1param1a, self.party1param1a],
27 [self.party1param2]]
28
29 def getGeneralTestStrings(self) ->List[str] :
30 return ["PartyRef.ws:party1.","PartyRef.ws:party1.\\{a=1\\}"]
31
32 def testSerialize(self) :
33 jackson = ObjectMapper()
34
35 jsonobj = jackson.toJson(self.party1param2)
36 print(jsonobj)
37 self.assertEqual(json.loads(self.serialized), jsonobj)
38
39 def testDeserialize(self):
40 jackson = ObjectMapper()
41 p = jackson.parse(json.loads(self.serialized), PartyWithParameters)
42 print(p)
43 self.assertEqual(self.party1param2, p)
Note: See TracBrowser for help on using the repository browser.