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.DeadlineRounds import DeadlineRounds
|
---|
9 |
|
---|
10 |
|
---|
11 | class DeadlineRoundsTest(unittest.TestCase):
|
---|
12 | pyson=ObjectMapper()
|
---|
13 | deadline = DeadlineRounds(10,1999)
|
---|
14 | deadline1 = DeadlineRounds(10,1999)
|
---|
15 | deadline2 = DeadlineRounds(10,4328)
|
---|
16 | deadline3 = DeadlineRounds(9,1999)
|
---|
17 | deadlinejson = {"DeadlineRounds":{'rounds':10, "durationms":1999}}
|
---|
18 |
|
---|
19 | def testDeserialization(self):
|
---|
20 | self.assertEqual(self.deadline, self.pyson.parse(self.deadlinejson, Deadline))
|
---|
21 |
|
---|
22 | def testSerialization(self):
|
---|
23 | print(self.pyson.toJson(self.deadline))
|
---|
24 | self.assertEqual(self.deadlinejson, self.pyson.toJson(self.deadline))
|
---|
25 |
|
---|
26 | def testRepr(self):
|
---|
27 | self.assertEqual("DeadlineRounds[10,1999]", repr(self.deadline))
|
---|
28 |
|
---|
29 | def testEqual(self):
|
---|
30 | self.assertEqual(self.deadline, self.deadline1)
|
---|
31 | self.assertNotEqual(self.deadline, self.deadline2)
|
---|
32 | self.assertNotEqual(self.deadline, self.deadline3)
|
---|
33 | self.assertEqual(hash(self.deadline), hash(self.deadline1))
|
---|
34 | self.assertNotEqual(hash(self.deadline), hash(self.deadline2))
|
---|
35 | self.assertNotEqual(hash(self.deadline), hash(self.deadline3))
|
---|
36 |
|
---|
37 | def testGetDuration(self):
|
---|
38 | self.assertEqual(1999, self.deadline.getDuration()) |
---|