Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tattoo committed Oct 18, 2023
1 parent f1c9b29 commit a30237f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/oxygen/robot3_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ def ms_to_timestamp(self, milliseconds):
tz_delta = self.get_timezone_delta()

time_object = datetime.fromtimestamp(int(milliseconds / 1000)) - tz_delta
milliseconds_delta = timedelta(milliseconds=(milliseconds % 1000))
time_object = (time_object + milliseconds_delta)
if time_object.year < 1970:
time_object = datetime.fromtimestamp(0)
# fromtimestamp() loses milliseconds, add them back
Expand Down
5 changes: 2 additions & 3 deletions src/oxygen/robot4_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
TestCase as RobotResultTest,
TestSuite as RobotResultSuite)

from robot.model import BodyItem

from robot.running.model import TestSuite as RobotRunningSuite


Expand Down Expand Up @@ -227,6 +225,8 @@ def spawn_robot_keyword(self,
start_timestamp = self.ms_to_timestamp(start_time)
end_timestamp = self.ms_to_timestamp(end_time)

# import this here so RF4 interface stays in parity with RF3
from robot.model import BodyItem
if setup:
keyword_type = BodyItem.SETUP
elif teardown:
Expand Down Expand Up @@ -284,7 +284,6 @@ def timestamp_to_ms(self, timestamp):

return milliseconds


def ms_to_timestamp(self, milliseconds):
tz_delta = self.get_timezone_delta()

Expand Down
8 changes: 7 additions & 1 deletion tests/utest/robot_interface/test_time_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ def test_should_be_associative(self):

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

self.assertEqual(timestamp, expected)

def test_ms_before_epoch_are_reset_to_epoch(self):
from oxygen.robot4_interface import RobotResultInterface as RF4ResultIface
Expand Down

0 comments on commit a30237f

Please sign in to comment.