Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Tests

on:
push:
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -31,7 +30,7 @@ jobs:
matrix:
python: ${{ fromJSON(needs.generate-matrix.outputs.python-versions) }}
rf-version: ${{ fromJSON(needs.generate-matrix.outputs.rf-versions) }}
name: Windows (${{ matrix.python }}, robotframework-${{ matrix.rf-version }})
name: Windows (python-${{ matrix.python }}, robotframework-${{ matrix.rf-version }})
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand All @@ -51,7 +50,7 @@ jobs:
matrix:
python: ${{ fromJSON(needs.generate-matrix.outputs.python-versions) }}
rf-version: ${{ fromJSON(needs.generate-matrix.outputs.rf-versions) }}
name: Linux (${{ matrix.python }}, robotframework-${{ matrix.rf-version }})
name: Linux (python-${{ matrix.python }}, robotframework-${{ matrix.rf-version }})
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand All @@ -70,7 +69,7 @@ jobs:
matrix:
python: ${{ fromJSON(needs.generate-matrix.outputs.python-versions) }}
rf-version: ${{ fromJSON(needs.generate-matrix.outputs.rf-versions) }}
name: MacOS (${{ matrix.python }}, robotframework-${{ matrix.rf-version }})
name: MacOS (python-${{ matrix.python }}, robotframework-${{ matrix.rf-version }})
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion src/oxygen/oxygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def output_file(self, path):
result.visit(OxygenVisitor(self.run_time_data))
result.save()


class OxygenLibrary(OxygenCore):
'''Oxygen is a tool to consolidate different test tools' reports together
as a single Robot Framework log and report. ``oxygen.OxygenLibrary``
Expand Down
3 changes: 3 additions & 0 deletions src/oxygen/robot3_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ def ms_to_timestamp(self, milliseconds):
tz_delta = self.get_timezone_delta()

time_object = datetime.fromtimestamp(int(milliseconds / 1000)) - tz_delta
if time_object.year < 1970:
time_object = datetime.fromtimestamp(0)
# fromtimestamp() loses milliseconds, add them back
milliseconds_delta = timedelta(milliseconds=(milliseconds % 1000))
time_object = (time_object + milliseconds_delta)

Expand Down
8 changes: 5 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,11 +284,13 @@ def timestamp_to_ms(self, timestamp):

return milliseconds


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

time_object = datetime.fromtimestamp(int(milliseconds / 1000)) - tz_delta
if time_object.year < 1970:
time_object = datetime.fromtimestamp(0)
# fromtimestamp() loses milliseconds, add them back
milliseconds_delta = timedelta(milliseconds=(milliseconds % 1000))
time_object = (time_object + milliseconds_delta)

Expand Down
39 changes: 28 additions & 11 deletions tests/utest/robot_interface/test_time_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,42 @@ def setUp(self):

def test_should_be_correct(self):
timestamp = self.interface.result.ms_to_timestamp(1533625284100.0)
assert timestamp == '20180807 07:01:24.100000'
self.assertEqual(timestamp, '20180807 07:01:24.100000')

timestamp = self.interface.result.ms_to_timestamp(1533625284451.0)
assert timestamp == '20180807 07:01:24.451000'
self.assertEqual(timestamp, '20180807 07:01:24.451000')

def test_should_be_associative(self):
timestamp = '20180807 07:01:24.300000'

milliseconds = self.interface.result.timestamp_to_ms(timestamp)
assert milliseconds == 1533625284300.0
self.assertEqual(milliseconds, 1533625284300.0)

timestamp = self.interface.result.ms_to_timestamp(milliseconds)
assert timestamp == '20180807 07:01:24.300000'
self.assertEqual(timestamp, '20180807 07:01:24.300000')

milliseconds = self.interface.result.timestamp_to_ms(timestamp)
assert milliseconds == 1533625284300.0
self.assertEqual(milliseconds, 1533625284300.0)

timestamp = self.interface.result.ms_to_timestamp(milliseconds)
assert timestamp == '20180807 07:01:24.300000'
self.assertEqual(timestamp, '20180807 07:01:24.300000')

def _validate_timestamp(self, result):
timestamp = result.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'

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())

from oxygen.robot3_interface import RobotResultInterface as RF3ResultIface
self._validate_timestamp(RF3ResultIface())


class TestTimestampToMs(TestCase):
Expand All @@ -36,19 +53,19 @@ def setUp(self):

def test_should_be_correct(self):
milliseconds = self.iface.result.timestamp_to_ms('20180807 07:01:24.000')
assert milliseconds == 1533625284000.0
self.assertEqual(milliseconds, 1533625284000.0)

milliseconds = self.iface.result.timestamp_to_ms('20180807 07:01:24.555')
assert milliseconds == 1533625284555.0
self.assertEqual(milliseconds, 1533625284555.0)

def test_should_be_associative(self):
milliseconds = 1533625284300.0

timestamp = self.iface.result.ms_to_timestamp(milliseconds)
assert timestamp == '20180807 07:01:24.300000'
self.assertEqual(timestamp, '20180807 07:01:24.300000')

milliseconds = self.iface.result.timestamp_to_ms(timestamp)
assert milliseconds == 1533625284300.0
self.assertEqual(milliseconds, 1533625284300.0)

timestamp = self.iface.result.ms_to_timestamp(milliseconds)
assert timestamp == '20180807 07:01:24.300000'
self.assertEqual(timestamp, '20180807 07:01:24.300000')