source: geniuswebcore/test/geniusweb/protocol/session/TeamInfoTest.py@ 88

Last change on this file since 88 was 88, checked in by Bart Vastenhouw, 2 years ago

Added python SimpleRunner GUI

File size: 1.6 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.protocol.session.TeamInfo import TeamInfo
10from geniusweb.references.Parameters import Parameters
11from geniusweb.references.PartyRef import PartyRef
12from geniusweb.references.PartyWithParameters import PartyWithParameters
13from geniusweb.references.PartyWithProfile import PartyWithProfile
14from geniusweb.references.ProfileRef import ProfileRef
15
16
17class TeamInfoTest (unittest.TestCase, GeneralTests[TeamInfo]):
18
19 team1 = TeamInfo([])
20 team1a = TeamInfo([])
21 parameters = Parameters()
22 asString1 = "{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"}]}}";
23
24 partyref = PartyRef(URI("party1"))
25 profileref = ProfileRef(URI("profile1"))
26 team2 = TeamInfo( [PartyWithProfile(PartyWithParameters(partyref, parameters),profileref)])
27 team2a = TeamInfo( [ PartyWithProfile(PartyWithParameters(partyref, parameters),
28 profileref)]);
29
30 def getGeneralTestData(self)->List[List[TeamInfo]] :
31 return [[self.team1, self.team1a], [self.team2, self.team2a]]
32
33 def getGeneralTestStrings(self) -> List[str]:
34 return ["TeamInfo.\\[\\].",
35 "TeamInfo.\\[PartyWithProfile.*party1.*profile1.*\\].*"]
36
37 def testSerialize(self) :
38
39 jackson = ObjectMapper()
40 print(jackson.toJson(self.team2))
41 self.assertEqual(json.loads(self.asString1), jackson.toJson(self.team2))
42
43 def testDeserialize(self) :
44 jackson = ObjectMapper()
45 read = jackson.parse(json.loads(self.asString1), TeamInfo)
46 self.assertEqual(self.team2, read)
Note: See TracBrowser for help on using the repository browser.