Skip to content

Commit

Permalink
Get environment reviews endpoint returns latest builds reviews only
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo committed Oct 9, 2024
1 parent b0c070b commit 5f50560
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/test_observer/controllers/artefacts/artefacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ def get_environment_reviews(
)
),
):
return [review for build in artefact.builds for review in build.environment_reviews]
return [
review
for build in artefact.latest_builds
for review in build.environment_reviews
]


@router.patch(
Expand Down
24 changes: 24 additions & 0 deletions backend/tests/controllers/artefacts/test_artefacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,30 @@ def test_get_with_two_environment_reviews(
]


def test_get_only_consideres_latest_builds(
test_client: TestClient, generator: DataGenerator
):
a = generator.gen_artefact("beta")
ab1 = generator.gen_artefact_build(a, revision=1)
ab2 = generator.gen_artefact_build(a, revision=2)
e1 = generator.gen_environment("env1")
e2 = generator.gen_environment("env2")
generator.gen_artefact_build_environment_review(ab1.id, e1.id)
review2 = generator.gen_artefact_build_environment_review(ab2.id, e2.id)

response = test_client.get(f"/v1/artefacts/{a.id}/environment-reviews")
assert response.status_code == 200
assert response.json() == [
{
"id": review2.id,
"review_decision": review2.review_decision,
"review_comment": review2.review_comment,
"environment_id": review2.environment_id,
"artefact_build_id": review2.artefact_build_id,
},
]


def test_review_an_environment(test_client: TestClient, generator: DataGenerator):
a = generator.gen_artefact("beta")
ab = generator.gen_artefact_build(a)
Expand Down

0 comments on commit 5f50560

Please sign in to comment.