Skip to content

Commit dbb74bf

Browse files
Further fix after review
1 parent 3ef267e commit dbb74bf

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/pysonar_scanner/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from enum import Enum
2525

2626
OsStr = typing.Literal["windows", "linux", "mac", "alpine", "other"]
27-
ArchStr = typing.Literal["x86_64", "aarch64", "x86"]
27+
ArchStr = typing.Literal["x64", "aarch64", "other"]
2828

2929

3030
def remove_trailing_slash(url: str) -> str:

tests/sq_api_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ def mock_analysis_jres(
8080
self,
8181
body: Optional[list[dict]] = None,
8282
status: int = 200,
83+
os_matcher: Optional[str] = "linux",
84+
arch_matcher: Optional[str] = "x64",
8385
) -> responses.BaseResponse:
8486
return self.rsps.get(
8587
url=f"{self.api_url}/analysis/jres",
8688
json=body,
8789
status=status,
8890
match=[
8991
matchers.header_matcher({"Accept": "application/json"}),
92+
matchers.query_param_matcher(utils.filter_none_values({"os": os_matcher, "arch": arch_matcher})),
9093
],
9194
)
9295

tests/test_api.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,17 @@ def test_get_analysis_jres(self):
317317
),
318318
]
319319

320-
with self.subTest("get_analysis_jres works"), sq_api_mocker() as mocker:
320+
with self.subTest("get_analysis_jres works (linux)"), sq_api_mocker() as mocker:
321321
mocker.mock_analysis_jres([sq_api_utils.jre_to_dict(jre) for jre in expected_jres])
322322

323-
actual_jres = self.sq.get_analysis_jres(os="linux", arch="x86_64")
323+
actual_jres = self.sq.get_analysis_jres(os="linux", arch="x64")
324+
self.assertEqual(actual_jres, expected_jres)
325+
326+
with self.subTest("get_analysis_jres works (windows)"), sq_api_mocker() as mocker:
327+
mocker.mock_analysis_jres(
328+
[sq_api_utils.jre_to_dict(jre) for jre in expected_jres], os_matcher="windows", arch_matcher="aarch64"
329+
)
330+
actual_jres = self.sq.get_analysis_jres(os="windows", arch="aarch64")
324331
self.assertEqual(actual_jres, expected_jres)
325332

326333
with (
@@ -329,15 +336,15 @@ def test_get_analysis_jres(self):
329336
self.assertRaises(SonarQubeApiException),
330337
):
331338
mocker.mock_analysis_jres(status=404)
332-
self.sq.get_analysis_jres(os="linux", arch="x86_64")
339+
self.sq.get_analysis_jres(os="linux", arch="x64")
333340

334341
with (
335342
self.subTest("get_analysis_jres returns error when keys are missing"),
336343
sq_api_mocker() as mocker,
337344
self.assertRaises(SonarQubeApiException),
338345
):
339346
mocker.mock_analysis_jres([{"id": "jre1"}])
340-
self.sq.get_analysis_jres(os="linux", arch="x86_64")
347+
self.sq.get_analysis_jres(os="linux", arch="x64")
341348

342349
def test_download_analysis_jre(self):
343350
jre_id = "jre1"

tests/test_jre.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242

4343
@patch("pysonar_scanner.utils.get_os", return_value=Os.LINUX)
44-
@patch("pysonar_scanner.utils.get_arch", return_value=Arch.AARCH64)
44+
@patch("pysonar_scanner.utils.get_arch", return_value=Arch.X64)
4545
class TestJREProvisioner(pyfakefs.TestCase):
4646
def setUp(self):
4747
self.setUpPyfakefs(allow_root_user=False)
@@ -115,7 +115,7 @@ def __setup_tar_file(self):
115115

116116
def test_if_patching_worked(self, get_os_mock, get_arch_mock):
117117
self.assertEqual(utils.get_os(), Os.LINUX)
118-
self.assertEqual(utils.get_arch(), Arch.AARCH64)
118+
self.assertEqual(utils.get_arch(), Arch.X64)
119119

120120
def test_successfully_downloading_jre(self, get_os_mock, get_arch_mock):
121121
class JRETestCase(TypedDict):

0 commit comments

Comments
 (0)