source: geniuswebcore/test/geniusweb/actions/LearningDoneTest.py

Last change on this file was 111, checked in by ruud, 2 months ago

Modifications for automatic java to python conversion. Overloaded methods now have different names.

File size: 2.0 KB
Line 
1# Generated from java by J2P
2from __future__ import annotations
3from decimal import Decimal
4from geniusweb.actions.Action import Action
5from geniusweb.actions.LearningDone import LearningDone
6from geniusweb.actions.PartyId import PartyId
7from pyson.ObjectMapper import ObjectMapper
8from typing import List
9from typing import Optional
10from unitpy.GeneralTests import GeneralTests
11from unitpy.RunWith import RunWith
12from unitpy.Runner import JUnit4ClassRunner
13from unitpy.Runner import runTests
14from unitpy.Test import Test
15from unittest import TestCase
16import json
17
18
19@RunWith(JUnit4ClassRunner)
20class LearningDoneTest(GeneralTests):
21
22 #Override
23 def getGeneralTestData(self) -> Optional[List[Optional[List[Optional[LearningDone]]]]]:
24 return [[self.__done,self.__done1],(lambda _: _ if type(_)==list else [_])(self.__done2)]
25
26 #Override
27 def getGeneralTestStrings(self) -> Optional[List[Optional[str]]]:
28 return ["LearningDone\\[.*" + str(self.__id) + ".*\\]","LearningDone\\[.*" + str(self.__idb) + ".*\\]"]
29
30 @Test()
31 def serializeEndNegoTest(self) -> None:
32 # System.out.println(jackson.writeValueAsString(done));
33 TestCase().assertEqual(self.__endnegostring,json.dumps(self.__jackson.toJson(self.__done),separators=(',', ':')))
34
35 @Test()
36 def deserializeEndNegoTest(self) -> None:
37 act:Optional[Action] = self.__jackson.parse(json.loads(self.__endnegostring, parse_float=lambda _:Decimal(_)),Action)
38 TestCase().assertEqual(self.__done,act)
39
40 def __init__(self):
41 self.__jackson:Optional[ObjectMapper] = ObjectMapper()
42 self.__id:Optional[PartyId] = PartyId("party1")
43 self.__idb:Optional[PartyId] = PartyId("party2")
44 self.__done:Optional[LearningDone] = LearningDone(self.__id)
45 self.__done1:Optional[LearningDone] = LearningDone(self.__id)
46 self.__done2:Optional[LearningDone] = LearningDone(self.__idb)
47 self.__endnegostring:Optional[str] = "{\"LearningDone\":{\"actor\":\"party1\"}}"
48 super().__init__()
49
50class Test(TestCase):
51 def test(self):
52 runTests(LearningDoneTest)
Note: See TracBrowser for help on using the repository browser.