Skip to content

Commit

Permalink
test: build issues view
Browse files Browse the repository at this point in the history
Closes #972
  • Loading branch information
murilx committed Mar 10, 2025
1 parent ba94951 commit 0ada165
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
33 changes: 33 additions & 0 deletions backend/kernelCI_app/unitTests/buildDetails_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
build_details_expected_fields,
build_tests_expected_fields,
)
from kernelCI_app.unitTests.utils.fields.issues import issues_resource_fields
from kernelCI_app.utils import string_to_json
import pytest
from http import HTTPStatus
Expand Down Expand Up @@ -73,3 +74,35 @@ def test_get_build_tests(
assert_has_fields_in_response_content(
fields=build_tests_expected_fields, response_content=test
)


@online
@pytest.mark.parametrize(
"build_id, status_code, has_error_body",
[
("maestro:67cb7656180183719578336e", HTTPStatus.OK, False),
("invalid_id", HTTPStatus.OK, True),
],
)
def test_get_build_issues(
pytestconfig, build_id: str, status_code: HTTPStatus, has_error_body: bool
) -> None:
response = client.get_build_issues(build_id=build_id)
content = string_to_json(response.content.decode())
assert_status_code_and_error_response(
content=content,
response=response,
status_code=status_code,
should_error=has_error_body,
)

if not has_error_body:
assert_has_fields_in_response_content(
fields=issues_resource_fields, response_content=content[0]
)

if pytestconfig.getoption("--run-all") and len(content) > 1:
for issue in content[1:]:
assert_has_fields_in_response_content(
fields=issues_resource_fields, response_content=issue
)
5 changes: 5 additions & 0 deletions backend/kernelCI_app/unitTests/utils/client/buildClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ def get_build_tests(self, *, build_id: str) -> requests.Response:
path = reverse("buildTests", kwargs={"build_id": build_id})
url = self.get_endpoint(path=path)
return requests.get(url)

def get_build_issues(self, *, build_id: str) -> requests.Response:
path = reverse("buildIssues", kwargs={"build_id": build_id})
url = self.get_endpoint(path=path)
return requests.get(url)
4 changes: 3 additions & 1 deletion backend/kernelCI_app/unitTests/utils/fields/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

issues_resource_fields = [
"id",
"comment",
"version",
"comment",
"report_url",
"incidents_info",
]

0 comments on commit 0ada165

Please sign in to comment.