1919#
2020import pytest
2121from tests .its .utils .sonarqube_client import SonarQubeClient
22- from tests .its .utils .cli_client import CliClient
22+ from tests .its .utils .cli_client import CliClient , SOURCES_FOLDER_PATH
2323
2424
2525pytestmark = pytest .mark .its
@@ -30,19 +30,17 @@ def test_auto_detect_tests_from_pyproject_toml(sonarqube_client: SonarQubeClient
3030 process = cli .run_analysis (sources_dir = "with-tests" , params = ["--verbose" ])
3131 assert process .returncode == 0 , process .stdout
3232
33- task = sonarqube_client . get_latest_ce_task ( )
34- projects = sonarqube_client . search_projects ()
35- project_keys = [ p [ "key" ] for p in projects ]
33+ task_id = cli . _read_ce_task_id ( SOURCES_FOLDER_PATH / "with-tests" )
34+ assert task_id is not None , f"report-task.txt not written — analysis may have failed early. \n Scanner output: \n { process . stdout } "
35+ task = sonarqube_client . get_ce_task_by_id ( task_id )
3636
37- assert task is not None and task ["status" ] == "SUCCESS" , (
37+ assert task ["status" ] == "SUCCESS" , (
3838 f"SonarQube CE task did not succeed.\n "
3939 f"Task: { task } \n "
40- f"Existing projects: { project_keys } \n "
4140 f"Scanner output:\n { process .stdout } "
4241 )
4342 assert task .get ("componentKey" ) == "with-tests" , (
4443 f"CE task succeeded for wrong component '{ task .get ('componentKey' )} ', expected 'with-tests'.\n "
45- f"Existing projects: { project_keys } \n "
4644 f"Scanner output:\n { process .stdout } "
4745 )
4846
0 commit comments