|
| 1 | +# Copyright 2024 EPAM Systems |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +from unittest import mock |
| 16 | + |
| 17 | +from tests import REPORT_PORTAL_SERVICE |
| 18 | +from tests.helpers import utils |
| 19 | + |
| 20 | +EXAMPLE_TEST = 'examples/dynamic_test_case_id.robot' |
| 21 | + |
| 22 | + |
| 23 | +@mock.patch(REPORT_PORTAL_SERVICE) |
| 24 | +def test_case_id_simple(mock_client_init): |
| 25 | + result = utils.run_robot_tests([EXAMPLE_TEST], arguments={'--metadata': 'Scope:Smoke'}) |
| 26 | + assert result == 0 # the test successfully passed |
| 27 | + |
| 28 | + mock_client = mock_client_init.return_value |
| 29 | + launch_start = mock_client.start_launch.call_args_list |
| 30 | + launch_finish = mock_client.finish_launch.call_args_list |
| 31 | + assert len(launch_start) == len(launch_finish) == 1 |
| 32 | + |
| 33 | + item_start_calls = mock_client.start_test_item.call_args_list |
| 34 | + item_finish_calls = mock_client.finish_test_item.call_args_list |
| 35 | + assert len(item_start_calls) == len(item_finish_calls) == 3 |
| 36 | + |
| 37 | + test_item_start = item_start_calls[-2] |
| 38 | + assert test_item_start[1]['test_case_id'] == f'{EXAMPLE_TEST}:Test set dynamic Test Case ID' |
| 39 | + |
| 40 | + test_item_finish = item_finish_calls[-2] |
| 41 | + assert test_item_finish[1]['test_case_id'] == 'dynamic_tags.robot[Smoke]' |
0 commit comments