source: geniuswebcore/test/geniusweb/issuevalue/DiscreteValueSetTest.py@ 66

Last change on this file since 66 was 59, checked in by Wouter Pasman, 3 years ago

#44 manual commit of first public release, because this will cause the dist directory to move

File size: 1.3 KB
Line 
1import unittest
2
3from pyson.ObjectMapper import ObjectMapper
4
5from geniusweb.issuevalue.DiscreteValue import DiscreteValue
6from geniusweb.issuevalue.DiscreteValueSet import DiscreteValueSet
7from geniusweb.issuevalue.ValueSet import ValueSet
8
9
10class 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
Note: See TracBrowser for help on using the repository browser.