source: geniuswebcore/test/geniusweb/bidspace/AllBidsListTest.py@ 73

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

Fix for IssueValue hashcode.

File size: 1.9 KB
Line 
1from decimal import Decimal
2from typing import Collection, List, Dict
3import unittest
4
5from tudelft.utilities.immutablelist.Range import Range
6
7from geniusweb.bidspace.AllBidsList import AllBidsList
8from geniusweb.issuevalue.Bid import Bid
9from geniusweb.issuevalue.DiscreteValue import DiscreteValue
10from geniusweb.issuevalue.DiscreteValueSet import DiscreteValueSet
11from geniusweb.issuevalue.Domain import Domain
12from geniusweb.issuevalue.NumberValue import NumberValue
13from geniusweb.issuevalue.NumberValueSet import NumberValueSet
14from geniusweb.issuevalue.ValueSet import ValueSet
15
16
17class AllBidsListTest(unittest.TestCase):
18 I1V2 = DiscreteValue("i1v2")
19 I1V1 = DiscreteValue("i1v1")
20 I2V1 = NumberValue(Decimal("2.00"))
21 I2V2 = NumberValue(Decimal("2.45"))
22
23 I2V3 = NumberValue(Decimal("2.90"))
24 DOMAINNAME = "testdomain"
25
26 ISSUE1 = "issue1"
27 ISSUE2 = "issue2"
28 issues:Dict[str, ValueSet] = {}
29
30
31 discretevalues1:List[DiscreteValue] = [I1V1, I1V2]
32 values1 = DiscreteValueSet(discretevalues1)
33
34 issues[ISSUE1]= values1
35
36 values2 = NumberValueSet(Range(Decimal("2"), Decimal("3"), Decimal("0.45")))
37 issues[ISSUE2]=values2
38
39 domain = Domain(DOMAINNAME, issues)
40 allBidsList = AllBidsList(domain)
41
42 print(str(allBidsList))
43
44 def testListElements(self):
45 self.assertEqual(6, self.allBidsList.size())
46 allbids = [bid for bid in self.allBidsList]
47 self.assertTrue(Bid({self.ISSUE1:self.I1V1, self.ISSUE2:self.I2V1}) in allbids)
48 self.assertTrue(Bid({self.ISSUE1:self.I1V1, self.ISSUE2:self.I2V2}) in allbids)
49 self.assertTrue(Bid({self.ISSUE1:self.I1V1, self.ISSUE2:self.I2V3}) in allbids)
50 self.assertTrue(Bid({self.ISSUE1:self.I1V2, self.ISSUE2:self.I2V1}) in allbids)
51 self.assertTrue(Bid({self.ISSUE1:self.I1V2, self.ISSUE2:self.I2V1}) in allbids)
52 self.assertTrue(Bid({self.ISSUE1:self.I1V2, self.ISSUE2:self.I2V3}) in allbids)
53
Note: See TracBrowser for help on using the repository browser.