source: geniuswebcore/test/geniusweb/issuevalue/DiscreteValueTest.py@ 78

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

Fix for IssueValue hashcode.

File size: 1.2 KB
Line 
1import json
2from pickle import NONE
3from typing import List
4import unittest
5
6from pyson.ObjectMapper import ObjectMapper
7from unitpy.GeneralTests import GeneralTests
8
9from geniusweb.issuevalue.DiscreteValue import DiscreteValue
10from geniusweb.issuevalue.Value import Value
11
12
13class DiscreteValueTest(unittest.TestCase, GeneralTests[DiscreteValue]):
14 value = DiscreteValue("a")
15 value1 = DiscreteValue("a")
16 valueb = DiscreteValue("b")
17
18 serialized = "\"a\"";
19 jackson = ObjectMapper();
20
21 def testSerialize(self):
22 print(str(self.jackson.toJson(self.value)))
23 self.assertEqual(json.loads(self.serialized), self.jackson.toJson(self.value))
24
25 def testEmpty(self):
26 self.assertRaises(ValueError, lambda:DiscreteValue(""))
27
28 def testDeserialize(self) :
29 self.assertEqual(self.value, self.jackson.parse(json.loads(self.serialized), DiscreteValue))
30
31 def testDeserializeFromValue(self):
32 self.assertEqual(self.value, self.jackson.parse(json.loads(self.serialized), Value))
33
34 def getGeneralTestData(self)->List[List[DiscreteValue]] :
35 return [ [self.value, self.value1], [self.valueb]]
36
37 def getGeneralTestStrings(self)->List[str]:
38 return [self.serialized, "\"b\""]
39
Note: See TracBrowser for help on using the repository browser.