source: geniuswebcore/test/geniusweb/simplerunner/SessionRunnerE2ETest.py@ 85

Last change on this file since 85 was 84, checked in by Bart Vastenhouw, 3 years ago

Added time-dependent parties for python and simpleRunner-GUI for java

File size: 2.1 KB
Line 
1from fileinput import filename
2import json
3from pathlib import Path
4import unittest
5from unittest.mock import Mock
6
7from pyson.ObjectMapper import ObjectMapper
8from tudelft_utilities_logging.ReportToLogger import ReportToLogger
9
10from geniusweb.protocol.NegoSettings import NegoSettings
11from geniusweb.simplerunner.ClassPathConnectionFactory import ClassPathConnectionFactory
12from geniusweb.simplerunner.NegoRunner import NegoRunner
13
14
15class SessionRunnerE2ETest(unittest.TestCase):
16 '''
17 E2E test doing a full real run of a session with real agents and protocol.
18 NOTICE This will exercise a full system to errors here may point far outside
19 this module.
20 '''
21 TEST_RUNTIME = 5000
22 jackson = ObjectMapper()
23 logger = Mock(ReportToLogger("test"))
24 filename:str
25 runner:NegoRunner
26
27 params = ["test/resources/settings.json",
28# "test/resources/settings2.json" , PARTIALORDERING NOT YET
29 "test/resources/settingsbadprofile.json",
30# "test/resources/shaoptoursettings.json", ALLPERMUTATIONSETTINGS NOT YET
31 "test/resources/mopac.json"
32# "test/resources/tournament.json" ALLPERMUTATIONSETTINGS NOT YET
33 ]
34
35
36
37 def testAll(self):
38 '''
39 runs all the tests. Python has no standard 'parameterized' mechanism
40 so we have to do it ourselves.
41 '''
42 for filename in self.params:
43 self.filename=filename
44 with self.subTest("before "+self.filename):
45 self.before()
46 with self.subTest("runMain"+self.filename):
47 self.runTestMainFunction()
48
49 def before(self):
50 print("Running from file " + self.filename)
51 serialized = Path(self.filename).read_text("utf-8")
52 settings=self.jackson.parse(json.loads(serialized), NegoSettings)
53 self.runner = NegoRunner(settings, ClassPathConnectionFactory(),
54 self.logger,self.TEST_RUNTIME)
55
56 def runTestMainFunction(self) :
57 NegoRunner.main([self.filename])
58
59 def runTest(self) :
60 self.runner.run()
61 print("Final state:\n" + str(self.runner.getProtocol().getState()))
62 self.assertTrue(self.runner.isProperlyStopped())
63 # check no warnings and more severe
64 self.asssertEqual([], self.logger.log.call_args_list)
Note: See TracBrowser for help on using the repository browser.