|
| 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 | +import pytest |
| 18 | + |
| 19 | +from custom_name.test_custom_name_args import TEST_NAME_ARGS |
| 20 | +from custom_name.test_custom_name_empty import TEST_NAME_EMPTY |
| 21 | +from custom_name.test_custom_name_kwargs import TEST_NAME_KWARGS |
| 22 | +from tests import REPORT_PORTAL_SERVICE |
| 23 | +from tests.helpers import utils |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.parametrize('test, expected', [ |
| 27 | + ('examples/custom_name/test_custom_name_args.py', TEST_NAME_ARGS), |
| 28 | + ('examples/custom_name/test_custom_name_kwargs.py', TEST_NAME_KWARGS), |
| 29 | + ('examples/custom_name/test_custom_name_empty.py', TEST_NAME_EMPTY) |
| 30 | +]) |
| 31 | +@mock.patch(REPORT_PORTAL_SERVICE) |
| 32 | +def test_custom_attribute_report(mock_client_init, test, expected): |
| 33 | + result = utils.run_pytest_tests(tests=[test], variables=utils.DEFAULT_VARIABLES) |
| 34 | + assert int(result) == 0, 'Exit code should be 0 (no errors)' |
| 35 | + |
| 36 | + mock_client = mock_client_init.return_value |
| 37 | + start_count = mock_client.start_test_item.call_count |
| 38 | + finish_count = mock_client.finish_test_item.call_count |
| 39 | + assert start_count == finish_count == 1, 'Incorrect number of "start_test_item" or "finish_test_item" calls' |
| 40 | + |
| 41 | + call_args = mock_client.start_test_item.call_args_list |
| 42 | + step_call_args = call_args[0][1] |
| 43 | + assert step_call_args['name'] == expected, 'Incorrect item name' |
0 commit comments