|
13 | 13 | limitations under the License |
14 | 14 | """ |
15 | 15 |
|
| 16 | +import sys |
16 | 17 | import pytest |
17 | 18 |
|
| 19 | +from robotframework_reportportal.result_visitor import to_timestamp |
| 20 | +from robotframework_reportportal.variables import _variables |
18 | 21 |
|
19 | | -class TestResultVisitorTest: |
20 | 22 |
|
21 | | - def test_parse_message_no_img_tag(self, visitor): |
22 | | - with pytest.raises(AttributeError): |
23 | | - visitor.parse_message('usual test comment without image') |
| 23 | +def test_parse_message_no_img_tag(visitor): |
| 24 | + with pytest.raises(AttributeError): |
| 25 | + visitor.parse_message('usual test comment without image') |
24 | 26 |
|
25 | | - def test_parse_message_bad_img_tag(self, visitor): |
26 | | - with pytest.raises(AttributeError): |
27 | | - visitor.parse_message('<img src=\'bad.html.img>') |
28 | 27 |
|
29 | | - def test_parse_message_contains_image(self, visitor): |
30 | | - assert ['src="any.png"', 'any.png'] == visitor.parse_message( |
31 | | - '<img alt="" src="any.png" />') |
| 28 | +def test_parse_message_bad_img_tag(visitor): |
| 29 | + with pytest.raises(AttributeError): |
| 30 | + visitor.parse_message('<img src=\'bad.html.img>') |
32 | 31 |
|
33 | | - def test_parse_message_contains_image_with_space(self, visitor): |
34 | | - assert ['src="any%20image.png"', 'any image.png'] == \ |
35 | | - visitor.parse_message('<img alt="" src="any%20image.png" />') |
| 32 | + |
| 33 | +def test_parse_message_contains_image(visitor): |
| 34 | + assert ['src="any.png"', 'any.png'] == visitor.parse_message( |
| 35 | + '<img alt="" src="any.png" />') |
| 36 | + |
| 37 | + |
| 38 | +def test_parse_message_contains_image_with_space(visitor): |
| 39 | + assert ['src="any%20image.png"', 'any image.png'] == \ |
| 40 | + visitor.parse_message('<img alt="" src="any%20image.png" />') |
| 41 | + |
| 42 | + |
| 43 | +TIMESTAMP_TEST_CASES = [ |
| 44 | + ('20240920 00:00:00.000', '+3:00', '1726779600000'), |
| 45 | + ('20240919 18:00:00.000', '-3:00', '1726779600000') |
| 46 | +] |
| 47 | + |
| 48 | +if sys.version_info >= (3, 9): |
| 49 | + TIMESTAMP_TEST_CASES += [ |
| 50 | + ('20240919 23:00:00.000', 'Europe/Warsaw', '1726779600000'), |
| 51 | + ('20240920 00:00:00.000', 'UTC', '1726790400000'), |
| 52 | + ('20240919 19:00:00.000', 'EST', '1726790400000') |
| 53 | + ] |
| 54 | + |
| 55 | + |
| 56 | +@pytest.mark.parametrize('time_str, time_shift, expected', TIMESTAMP_TEST_CASES) |
| 57 | +def test_time_stamp_conversion(time_str, time_shift, expected): |
| 58 | + _variables['RP_TIME_ZONE_OFFSET'] = time_shift |
| 59 | + assert to_timestamp(time_str) == expected |
0 commit comments