@@ -168,3 +168,40 @@ def test_rp_tests_attributes_add(mock_client_init):
168168 assert len (attributes ) == 2
169169 assert {"key" : "scope" , "value" : "smoke" } in attributes
170170 assert {"key" : "test_key" , "value" : "test_value" } in attributes
171+
172+
173+ @mock .patch (REPORT_PORTAL_SERVICE )
174+ def test_rp_tests_attributes_string_split_and_deduplicated (mock_client_init , monkeypatch ):
175+ """Verify string `rp_tests_attributes` are split and deduplicated."""
176+ monkeypatch .setenv ("RP_TESTS_ATTRIBUTES" , " test_key:test_value ; smoke ; test_key:test_value " )
177+ variables = {}
178+ variables .update (utils .DEFAULT_VARIABLES .items ())
179+ result = utils .run_pytest_tests (tests = ["examples/test_simple.py" ], variables = variables )
180+ assert int (result ) == 0 , "Exit code should be 0 (no errors)"
181+
182+ mock_client = mock_client_init .return_value
183+ assert mock_client .start_test_item .call_count > 0 , '"start_test_item" called incorrect number of times'
184+
185+ call_args = mock_client .start_test_item .call_args_list
186+ step_call_args = call_args [- 1 ][1 ]
187+ actual_attributes = step_call_args ["attributes" ]
188+
189+ assert utils .attributes_to_tuples (actual_attributes ) == {("test_key" , "test_value" ), (None , "smoke" )}
190+
191+
192+ @mock .patch (REPORT_PORTAL_SERVICE )
193+ def test_rp_launch_attributes_string_split_and_deduplicated (mock_client_init , monkeypatch ):
194+ """Verify string `rp_launch_attributes` are split and deduplicated."""
195+ monkeypatch .setenv ("RP_LAUNCH_ATTRIBUTES" , " launch_key:launch_value ; smoke ; launch_key:launch_value " )
196+ variables = {}
197+ variables .update (utils .DEFAULT_VARIABLES .items ())
198+ result = utils .run_pytest_tests (tests = ["examples/test_simple.py" ], variables = variables )
199+ assert int (result ) == 0 , "Exit code should be 0 (no errors)"
200+
201+ mock_client = mock_client_init .return_value
202+ assert mock_client .start_launch .call_count > 0 , '"start_launch" called incorrect number of times'
203+
204+ launch_call_args = mock_client .start_launch .call_args_list
205+ launch_attributes = launch_call_args [0 ][1 ]["attributes" ]
206+
207+ assert {("launch_key" , "launch_value" ), (None , "smoke" )} <= utils .attributes_to_tuples (launch_attributes )
0 commit comments