Left: | ||
Right: |
OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the OLE Automation date implementation.""" | 3 """Tests for the OLE Automation date implementation.""" |
4 | 4 |
5 from __future__ import unicode_literals | 5 from __future__ import unicode_literals |
6 | 6 |
7 import decimal | |
7 import unittest | 8 import unittest |
8 | 9 |
9 from dfdatetime import ole_automation_date | 10 from dfdatetime import ole_automation_date |
10 | 11 |
11 | 12 |
12 class OLEAutomationDateEpochTest(unittest.TestCase): | 13 class OLEAutomationDateEpochTest(unittest.TestCase): |
13 """Tests for the OLE Automation date epoch.""" | 14 """Tests for the OLE Automation date epoch.""" |
14 | 15 |
15 def testInitialize(self): | 16 def testInitialize(self): |
16 """Tests the __init__ function.""" | 17 """Tests the __init__ function.""" |
(...skipping 11 matching lines...) Expand all Loading... | |
28 ole_automation_date_object = ole_automation_date.OLEAutomationDate( | 29 ole_automation_date_object = ole_automation_date.OLEAutomationDate( |
29 timestamp=43044.480556) | 30 timestamp=43044.480556) |
30 self.assertEqual(ole_automation_date_object.timestamp, 43044.480556) | 31 self.assertEqual(ole_automation_date_object.timestamp, 43044.480556) |
31 | 32 |
32 ole_automation_date_object = ole_automation_date.OLEAutomationDate() | 33 ole_automation_date_object = ole_automation_date.OLEAutomationDate() |
33 self.assertIsNone(ole_automation_date_object.timestamp) | 34 self.assertIsNone(ole_automation_date_object.timestamp) |
34 | 35 |
35 def testGetNormalizedTimestamp(self): | 36 def testGetNormalizedTimestamp(self): |
36 """Tests the _GetNormalizedTimestamp function.""" | 37 """Tests the _GetNormalizedTimestamp function.""" |
37 ole_automation_date_object = ole_automation_date.OLEAutomationDate( | 38 ole_automation_date_object = ole_automation_date.OLEAutomationDate( |
38 timestamp=43044.480556) | 39 timestamp=decimal.Decimal('43044.480556')) |
Joachim Metz
2018/03/07 02:02:11
keep this a float
ep
2018/03/08 12:27:22
Done.
| |
39 | 40 |
40 normalized_timestamp = ole_automation_date_object._GetNormalizedTimestamp() | 41 normalized_timestamp = ole_automation_date_object._GetNormalizedTimestamp() |
41 self.assertEqual(normalized_timestamp, 1509881520.0384002) | 42 self.assertEqual(normalized_timestamp, decimal.Decimal('1509881520.038400')) |
42 | 43 |
43 ole_automation_date_object = ole_automation_date.OLEAutomationDate() | 44 ole_automation_date_object = ole_automation_date.OLEAutomationDate() |
44 | 45 |
45 normalized_timestamp = ole_automation_date_object._GetNormalizedTimestamp() | 46 normalized_timestamp = ole_automation_date_object._GetNormalizedTimestamp() |
46 self.assertIsNone(normalized_timestamp) | 47 self.assertIsNone(normalized_timestamp) |
47 | 48 |
48 def testCopyFromDateTimeString(self): | 49 def testCopyFromDateTimeString(self): |
49 """Tests the CopyFromDateTimeString function.""" | 50 """Tests the CopyFromDateTimeString function.""" |
50 ole_automation_date_object = ole_automation_date.OLEAutomationDate() | 51 ole_automation_date_object = ole_automation_date.OLEAutomationDate() |
51 | 52 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 self.assertEqual(date_tuple, (None, None, None)) | 104 self.assertEqual(date_tuple, (None, None, None)) |
104 | 105 |
105 ole_automation_date_object = ole_automation_date.OLEAutomationDate() | 106 ole_automation_date_object = ole_automation_date.OLEAutomationDate() |
106 | 107 |
107 date_tuple = ole_automation_date_object.GetDate() | 108 date_tuple = ole_automation_date_object.GetDate() |
108 self.assertEqual(date_tuple, (None, None, None)) | 109 self.assertEqual(date_tuple, (None, None, None)) |
109 | 110 |
110 | 111 |
111 if __name__ == '__main__': | 112 if __name__ == '__main__': |
112 unittest.main() | 113 unittest.main() |
OLD | NEW |