source: geniuswebcore/test/geniusweb/deadline/DeadlineTimeTest.py@ 92

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

Refactor to help reusing partiesserver.

File size: 1.2 KB
Line 
1
2from datetime import datetime
3import unittest
4
5from pyson.ObjectMapper import ObjectMapper
6
7from geniusweb.deadline.Deadline import Deadline
8from geniusweb.deadline.DeadlineTime import DeadlineTime
9
10
11class DeadlineTimeTest(unittest.TestCase):
12 pyson=ObjectMapper()
13 deadline = DeadlineTime(1999)
14 deadline1 = DeadlineTime(1999)
15 deadline2 = DeadlineTime(4328)
16 deadlinejson = {"DeadlineTime":{"durationms":1999}}
17
18 def testDeserialization(self):
19 self.assertEqual(self.deadline, self.pyson.parse(self.deadlinejson, Deadline))
20
21 def testSerialization(self):
22 print(self.pyson.toJson(self.deadline))
23 self.assertEqual(self.deadlinejson, self.pyson.toJson(self.deadline))
24
25 def testRepr(self):
26 self.assertEqual("DeadlineTime[1999]", repr(self.deadline))
27
28 def testEqual(self):
29 self.assertEqual(self.deadline, self.deadline1)
30 self.assertNotEqual(self.deadline, self.deadline2)
31 self.assertEqual(hash(self.deadline), hash(self.deadline1))
32 self.assertNotEqual(hash(self.deadline), hash(self.deadline2))
33
34 def testGetDuration(self):
35 self.assertEqual(1999, self.deadline.getDuration())
Note: See TracBrowser for help on using the repository browser.