source: geniuswebcore/test/geniusweb/bidspace/pareto/ParetoE2Etest.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.7 KB
Line 
1import json
2from pathlib import Path
3import unittest
4
5from pyson.ObjectMapper import ObjectMapper
6
7from geniusweb.bidspace.pareto.GenericPareto import GenericPareto
8from geniusweb.bidspace.pareto.ParetoLinearAdditive import ParetoLinearAdditive
9from geniusweb.profile.Profile import Profile
10
11
12class ParetoE2Etest (unittest.TestCase):
13 '''
14 Test pareto functionality with some real profiles in an e2e test
15 '''
16 jackson = ObjectMapper()
17
18 data = \
19 [\
20 [ "test/resources/jobs/jobs1.json", \
21 "test/resources/jobs/jobs2.json", 18 ], \
22 [ "test/resources/7issues/7issues1.json", \
23 "test/resources/7issues/7issues2.json", 557 ]\
24 ]
25
26 def testAll(self):
27 '''
28 runs all the tests. Python has no standard 'parameterized' mechanism
29 so we have to do it ourselves.
30 '''
31 for [profile1, profile2, expectedNr] in self.data:
32 self.path1 = profile1
33 self.path2 = profile2
34 self.expectedNrPoints = expectedNr
35 with self.subTest("checkGeneric " + self.path1 + "," + self.path2):
36 self.checkGenerciPareto()
37
38 def checkGenerciPareto(self):
39 file1 = Path(self.path1).read_text("utf-8")
40 profile1 = self.jackson.parse(json.loads(file1), Profile)
41
42 file2 = Path(self.path2).read_text("utf-8")
43 profile2 = self.jackson.parse(json.loads(file2), Profile)
44
45 profiles = [profile1, profile2]
46 linaddpareto = ParetoLinearAdditive(profiles)
47 print("linaddpareto result" + str(linaddpareto))
48 self.assertEqual(self.expectedNrPoints, len(linaddpareto.getPoints()))
49
50 if self.expectedNrPoints < 40:
51 generalpareto = GenericPareto(profiles)
52 self.assertEqual(generalpareto.getPoints(), linaddpareto.getPoints())
53 print("generalpareto result" + str(generalpareto))
54 else:
55 print("Skippedn generalpareto - expected too slow")
Note: See TracBrowser for help on using the repository browser.