Skip to content

Commit

Permalink
Fix test that fails on specific macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Tattoo committed Oct 20, 2023
1 parent 5bf9f29 commit 01ce7a9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/utest/robot_interface/test_time_conversions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from datetime import timedelta
from unittest import TestCase

from mock import patch

from oxygen.robot_interface import RobotInterface


Expand Down Expand Up @@ -29,22 +32,24 @@ def test_should_be_associative(self):
timestamp = self.interface.result.ms_to_timestamp(milliseconds)
self.assertEqual(timestamp, '20180807 07:01:24.300000')

def _validate_timestamp(self, result):
timestamp = result.ms_to_timestamp(-10)
def _validate_timestamp(self, interface):
timestamp = interface.ms_to_timestamp(-10)
expected = '19700101 00:00:00.990000'
import platform
# Particular Windows 10 calculates epoch differently ( T ʖ̯ T)
if platform.system() == 'Windows' and platform.version() == '10.0.19044':
expected = '19700101 02:00:00.990000'

#expected = '19700101 02:00:00.990000'
# return_value=timedelta(seconds=0)
self.assertEqual(timestamp, expected)

def test_ms_before_epoch_are_reset_to_epoch(self):
from oxygen.robot4_interface import RobotResultInterface as RF4ResultIface
self._validate_timestamp(RF4ResultIface())
with patch.object(RF4ResultIface, 'get_timezone_delta') as m:
m.return_value = timedelta(seconds=7200)
self._validate_timestamp(RF4ResultIface())

from oxygen.robot3_interface import RobotResultInterface as RF3ResultIface
self._validate_timestamp(RF3ResultIface())
with patch.object(RF3ResultIface, 'get_timezone_delta') as m:
m.return_value = timedelta(seconds=7200)
self._validate_timestamp(RF3ResultIface())


class TestTimestampToMs(TestCase):
Expand Down

0 comments on commit 01ce7a9

Please sign in to comment.