Skip to content

Commit 34d39f3

Browse files
committed
Fix tests
1 parent 1997ab8 commit 34d39f3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

sonar/projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def export_zip(self, asynchronous: bool = False, timeout: int = 180) -> tuple[st
675675
resp = self.post("project_dump/export", params={"key": self.key})
676676
except exceptions.ObjectNotFound as e:
677677
Project.CACHE.pop(self)
678-
return f"FAILED/{e.message}", None
678+
raise
679679
except exceptions.SonarException as e:
680680
return f"FAILED/{e.message}", None
681681
except RequestException as e:
@@ -713,7 +713,7 @@ def import_zip(self, asynchronous: bool = False, timeout: int = 180) -> str:
713713
if "Dump file does not exist" in e.message:
714714
return f"FAILED/{tasks.ZIP_MISSING}"
715715
Project.CACHE.pop(self)
716-
return "FAILED/PROJECT_NOT_FOUND"
716+
raise
717717
except exceptions.SonarException as e:
718718
if "Dump file does not exist" in e.message:
719719
return f"FAILED/{tasks.ZIP_MISSING}"

test/unit/test_projects.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,10 @@ def test_import_wrong_key(get_test_project: Generator[projects.Project]) -> None
248248
proj = get_test_project
249249
proj.key = tutil.NON_EXISTING_KEY
250250
if tutil.SQ.edition() in (c.EE, c.DCE):
251-
assert proj.import_zip(asynchronous=True) == "FAILED/PROJECT_NOT_FOUND"
252-
assert proj.import_zip(asynchronous=False) == "FAILED/PROJECT_NOT_FOUND"
251+
with pytest.raises(exceptions.ObjectNotFound):
252+
proj.import_zip(asynchronous=True)
253+
with pytest.raises(exceptions.ObjectNotFound):
254+
proj.import_zip(asynchronous=False)
253255
else:
254256
with pytest.raises(exceptions.UnsupportedOperation):
255257
proj.import_zip(asynchronous=True)

0 commit comments

Comments
 (0)