source: geniuswebcore/test/geniusweb/references/PartyRefTest.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: 1.2 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.PartyRef import PartyRef
10
11
12class PartyRefTest (unittest.TestCase, GeneralTests[PartyRef]):
13
14 asJson = "\"ws:localhost/party1\""
15
16 party1 = PartyRef( URI("ws:localhost/party1"))
17 party1a = PartyRef( URI("ws:localhost/party1"))
18 party2 = PartyRef(URI("ws:localhost/party2"))
19 party3 = PartyRef( URI("http:localhost/party3"))
20
21
22 def getGeneralTestData(self) -> List[List[PartyRef]]:
23 return [ [self.party1, self.party1a],[self.party2], [self.party3]]
24
25 def getGeneralTestStrings(self) -> List[str] :
26 return ["PartyRef.*party1.", "PartyRef.*party2.",
27 "PartyRef.*party3."]
28
29 def testSmoke(self) :
30 PartyRef(URI("ws:localhost"))
31
32 def testNull(self):
33 self.assertRaises(ValueError, lambda:PartyRef(None))
34
35 def testSerialize(self) :
36 jackson = ObjectMapper()
37
38 jsonobj = jackson.toJson(self.party1)
39 print(json.dumps(jsonobj))
40 self.assertEqual(self.asJson, json.dumps(jsonobj))
41
42 def testDeserialize(self):
43 jackson = ObjectMapper()
44 p = jackson.parse(json.loads(self.asJson), PartyRef);
45 print(p)
46 self.assertEqual(self.party1, p)
Note: See TracBrowser for help on using the repository browser.