[100] | 1 |
|
---|
| 2 | from datetime import datetime
|
---|
| 3 | import unittest
|
---|
| 4 |
|
---|
| 5 | from pyson.ObjectMapper import ObjectMapper
|
---|
| 6 |
|
---|
| 7 | from geniusweb.deadline.Deadline import Deadline
|
---|
| 8 | from geniusweb.deadline.DeadlineTime import DeadlineTime
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | class 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()) |
---|