Skip to content

Commit 8e93a1c

Browse files
authored
Merge pull request #1351 from okorach:fix-test-3
Fix Tests & regressions
2 parents 7490b8b + 9a45c28 commit 8e93a1c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

sonar/platform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def __lta_and_latest() -> tuple[tuple[int, int, int], tuple[int, int, int]]:
788788
_, tmpfile = tempfile.mkstemp(prefix="sonar-tools", suffix=".txt", text=True)
789789
try:
790790
with open(tmpfile, "w", encoding="utf-8") as fp:
791-
print(requests.get(_UPDATE_CENTER, headers=_SONAR_TOOLS_AGENT, timeout=10).text, file=fp)
791+
print(requests.get(_UPDATE_CENTER, headers={"user-agent": _SONAR_TOOLS_AGENT}, timeout=10).text, file=fp)
792792
with open(tmpfile, "r", encoding="utf-8") as fp:
793793
upd_center_props = jprops.load_properties(fp)
794794
v = upd_center_props.get("ltsVersion", "9.9.0").split(".")

sonar/users.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def update(self, **kwargs) -> User:
253253
params[p] = kwargs[p]
254254
if len(params) > 1:
255255
self.post(UPDATE_API, params=params)
256-
self.set_scm_accounts(kwargs.get("scmAccounts", ""))
256+
self.set_scm_accounts(kwargs.get("scmAccounts", None))
257257
if "login" in kwargs:
258258
new_login = kwargs["login"]
259259
if new_login not in _OBJECTS:
@@ -380,8 +380,7 @@ def to_json(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr
380380
:rtype: dict
381381
"""
382382
json_data = self._json.copy()
383-
scm = self.scm_accounts
384-
json_data["scmAccounts"] = util.list_to_csv(scm) if scm else None
383+
json_data["scmAccounts"] = self.scm_accounts
385384
json_data["groups"] = self.groups().copy()
386385
if export_settings.get("MODE", "") == "MIGRATION":
387386
return json_data

test/test_migration.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ def test_migration() -> None:
6868
assert json_config["users"]["olivier"]["externalProvider"] == "sonarqube"
6969

7070
u = json_config["users"]["olivier-korach65532"]
71-
assert u["externalProvider"] == "github"
7271
assert u["name"] == "Olivier Korach"
7372
assert not u["local"]
74-
assert u["externalLogin"] == "okorach"
75-
assert u["email"] == "[email protected]"
73+
if util.SQ.version() >= (10, 0, 0):
74+
assert u["externalProvider"] == "github"
75+
assert u["externalLogin"] == "okorach"
76+
assert u["email"] == "[email protected]"
77+
else:
78+
assert u["externalProvider"] == "sonarqube"
7679

7780
p = json_config["projects"]["okorach_sonar-tools"]
7881
assert "lastTaskScannerContext" in p["backgroundTasks"]
@@ -96,7 +99,8 @@ def test_migration() -> None:
9699
p = json_config["projects"]["checkstyle-issues"]
97100
assert len(p["branches"]["main"]["issues"]["thirdParty"]) > 0
98101

99-
assert json_config["projects"]["demo:gitlab-ci-maven"]["detectedCi"] == "GitLab CI"
100-
assert json_config["projects"]["demo:gitlab-actions-cli"]["detectedCi"] == "Github Actions"
102+
if util.SQ.version() >= (10, 0, 0):
103+
assert json_config["projects"]["demo:gitlab-ci-maven"]["detectedCi"] == "Gitlab CI"
104+
assert json_config["projects"]["demo:github-actions-cli"]["detectedCi"] == "Github Actions"
101105

102106
util.clean(util.JSON_FILE)

0 commit comments

Comments
 (0)