1 | import unittest
|
---|
2 |
|
---|
3 | from pyson.ObjectMapper import ObjectMapper
|
---|
4 |
|
---|
5 | from geniusweb.issuevalue.DiscreteValue import DiscreteValue
|
---|
6 | from geniusweb.issuevalue.DiscreteValueSet import DiscreteValueSet
|
---|
7 | from geniusweb.issuevalue.ValueSet import ValueSet
|
---|
8 |
|
---|
9 |
|
---|
10 | class DiscreteValueSetTest(unittest.TestCase):
|
---|
11 | pyson=ObjectMapper()
|
---|
12 | val = DiscreteValueSet([DiscreteValue("a"), DiscreteValue("b")])
|
---|
13 | val1 = DiscreteValueSet([DiscreteValue("a"), DiscreteValue("b")])
|
---|
14 | val2 = DiscreteValueSet([DiscreteValue("a"), DiscreteValue("c")])
|
---|
15 | valjson = {"values":["a","b"]}
|
---|
16 |
|
---|
17 | def testSerialize(self):
|
---|
18 | print(str(self.pyson.toJson(self.val)))
|
---|
19 | self.assertEqual(self.valjson, self.pyson.toJson(self.val))
|
---|
20 |
|
---|
21 | def testDeserialize(self):
|
---|
22 | self.assertEqual(self.val, self.pyson.parse(self.valjson, ValueSet))
|
---|
23 |
|
---|
24 |
|
---|
25 | def testIterator(self):
|
---|
26 | self.assertTrue(DiscreteValue("a") in self.val)
|
---|
27 |
|
---|
28 |
|
---|
29 | def testRepr(self):
|
---|
30 | self.assertEqual("DiscreteValueSet[a, b]", repr(self.val))
|
---|
31 |
|
---|
32 | def testEqual(self):
|
---|
33 | self.assertEqual(self.val, self.val1)
|
---|
34 | self.assertNotEqual(self.val, self.val2)
|
---|
35 | self.assertEqual(hash(self.val), hash(self.val1))
|
---|
36 | self.assertNotEqual(hash(self.val), hash(self.val2))
|
---|
37 | |
---|