|
| 1 | +from datetime import timedelta |
1 | 2 | from unittest import TestCase
|
2 | 3 |
|
| 4 | +from mock import patch |
| 5 | + |
3 | 6 | from oxygen.robot_interface import RobotInterface
|
4 | 7 |
|
5 | 8 |
|
@@ -29,22 +32,22 @@ def test_should_be_associative(self):
|
29 | 32 | timestamp = self.interface.result.ms_to_timestamp(milliseconds)
|
30 | 33 | self.assertEqual(timestamp, '20180807 07:01:24.300000')
|
31 | 34 |
|
32 |
| - def _validate_timestamp(self, result): |
33 |
| - timestamp = result.ms_to_timestamp(-10) |
| 35 | + def _validate_timestamp(self, interface): |
| 36 | + timestamp = interface.ms_to_timestamp(-10) |
34 | 37 | expected = '19700101 00:00:00.990000'
|
35 |
| - import platform |
36 |
| - # Particular Windows 10 calculates epoch differently ( T ʖ̯ T) |
37 |
| - if platform.system() == 'Windows' and platform.version() == '10.0.19044': |
38 |
| - expected = '19700101 02:00:00.990000' |
39 | 38 |
|
40 | 39 | self.assertEqual(timestamp, expected)
|
41 | 40 |
|
42 | 41 | def test_ms_before_epoch_are_reset_to_epoch(self):
|
43 | 42 | from oxygen.robot4_interface import RobotResultInterface as RF4ResultIface
|
44 |
| - self._validate_timestamp(RF4ResultIface()) |
| 43 | + with patch.object(RF4ResultIface, 'get_timezone_delta') as m: |
| 44 | + m.return_value = timedelta(seconds=7200) |
| 45 | + self._validate_timestamp(RF4ResultIface()) |
45 | 46 |
|
46 | 47 | from oxygen.robot3_interface import RobotResultInterface as RF3ResultIface
|
47 |
| - self._validate_timestamp(RF3ResultIface()) |
| 48 | + with patch.object(RF3ResultIface, 'get_timezone_delta') as m: |
| 49 | + m.return_value = timedelta(seconds=7200) |
| 50 | + self._validate_timestamp(RF3ResultIface()) |
48 | 51 |
|
49 | 52 |
|
50 | 53 | class TestTimestampToMs(TestCase):
|
|
0 commit comments