Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(releases): Implement threshold details GET #55969

Merged
merged 5 commits into from
Sep 14, 2023

Conversation

EricHasegawa
Copy link
Contributor

Basic GET endpoint for release thresholds -> pass in an org id, project id, and threshold id, get back the details of the matching threshold.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 10, 2023
@codecov
Copy link

codecov bot commented Sep 10, 2023

Codecov Report

Merging #55969 (f67269e) into master (41e8adc) will decrease coverage by 0.01%.
Report is 24 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #55969      +/-   ##
==========================================
- Coverage   78.67%   78.67%   -0.01%     
==========================================
  Files        5068     5070       +2     
  Lines      217677   217936     +259     
  Branches    36841    36881      +40     
==========================================
+ Hits       171254   171453     +199     
- Misses      40900    40958      +58     
- Partials     5523     5525       +2     
Files Changed Coverage
...sentry/api/serializers/models/release_threshold.py ø
.../sentry/api/endpoints/release_threshold_details.py 100.00%
src/sentry/api/urls.py 100.00%

@EricHasegawa EricHasegawa marked this pull request as ready for review September 11, 2023 20:30
@EricHasegawa EricHasegawa requested a review from a team as a code owner September 11, 2023 20:30
@EricHasegawa EricHasegawa requested review from a team and nhsiehgit September 11, 2023 20:30
Copy link
Contributor

@nhsiehgit nhsiehgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 pending Cathy's comment

"GET": ApiPublishStatus.PRIVATE,
}

def get(self, request: Request, project: Project, threshold_id: str) -> HttpResponse:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am assuming you will have a PUT (and maybe a DELETE), so it might be worth refactoring with a convert_args function so you already have the ReleaseThreshold object you're getting/modifying/deleting

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert_args just allows us to convert the path param (threshold_id) into the actual model instance, correct?

)
return Response(serialize(release_threshold, request.user), status=200)
except ReleaseThreshold.DoesNotExist:
return Response(status=404)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to raise ResourceDoesNotExist?

from sentry.testutils.cases import APITestCase


class ReleaseThresholdDetailsTest(APITestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: switch to using get_success_response and get_error_response over client.get.

Suggested change
class ReleaseThresholdDetailsTest(APITestCase):
class ReleaseThresholdDetailsTest(APITestCase):
endpoint = "sentry-api-0-project-release-thresholds-details"
method = "get"

Comment on lines 31 to 41
url = reverse(
"sentry-api-0-project-release-thresholds-details",
kwargs={
"organization_slug": self.organization.slug,
"project_slug": self.project.slug,
"threshold_id": 123,
},
)
response = self.client.get(url)

assert response.status_code == 404
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same nit, can switch to much shorter test request

Suggested change
url = reverse(
"sentry-api-0-project-release-thresholds-details",
kwargs={
"organization_slug": self.organization.slug,
"project_slug": self.project.slug,
"threshold_id": 123,
},
)
response = self.client.get(url)
assert response.status_code == 404
self.get_error_response(self.organization.slug, self.project.slug, 123, status_code=404)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... eh 🤷

I'm indifferent.
Sure it can make the tests shorter, but it makes them more difficult to decipher and obfuscates away what the test is actually testing for

Copy link
Contributor

@nhsiehgit nhsiehgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment comment comment

overall +1 pending nits from others

"GET": ApiPublishStatus.PRIVATE,
}

def get(self, request: Request, project: Project, threshold_id: str) -> HttpResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert_args just allows us to convert the path param (threshold_id) into the actual model instance, correct?

Comment on lines 31 to 41
url = reverse(
"sentry-api-0-project-release-thresholds-details",
kwargs={
"organization_slug": self.organization.slug,
"project_slug": self.project.slug,
"threshold_id": 123,
},
)
response = self.client.get(url)

assert response.status_code == 404
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... eh 🤷

I'm indifferent.
Sure it can make the tests shorter, but it makes them more difficult to decipher and obfuscates away what the test is actually testing for

@EricHasegawa EricHasegawa merged commit 6df760e into master Sep 14, 2023
50 checks passed
@EricHasegawa EricHasegawa deleted the EricHasegawa/threshold_details branch September 14, 2023 21:10
@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants