Repository navigation
Conversation
Add helper function to check if the issue number exists on bpo. set FAILURE_STATUS in the event that the issue does not exist. Fix #15
Codecov Report
@@ Coverage Diff @@
## master #72 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 14 14
Lines 923 953 +30
Branches 55 56 +1
=====================================
+ Hits 923 953 +30
Continue to review full report at Codecov.
|
| STATUS_CONTEXT = "bedevere/issue-number" | ||
| # Try to keep descriptions at or below 50 characters, else GitHub's CSS will truncate it. | ||
| _FAILURE_DESCRIPTION = 'No issue # in title or "skip issue" label found' | ||
| _FAILURE_DESCRIPTION = 'Issue does not exit, No issue # in title or "skip issue" label found' |
There was a problem hiding this comment.
This felt a little dirty, but I was not sure if we wanted to "yet another" edge case of failure description. Happy to refactor this if we want to be more specific of the reason for failure.
There was a problem hiding this comment.
Hmm, this might be too long as a status check message.
I'm thinking it can be a separate status check, maybe "bedevere/valid-issue"? @brettcannon, what do you think?
There was a problem hiding this comment.
I don't think we need another status check (we are already at 4). Is there any reason the message can't be dynamically specified like for the NEWS.d check? In this instance the current message is the one that shows up if anything is found, but if an issue number is discovered but found not to exist, a different message saying something like "issue #NNNN not found at bugs.python.org" or something would be set while still flagging a status check failure.
Make sense?
There was a problem hiding this comment.
Using a different message sounds good :)
There was a problem hiding this comment.
Corrections to message: /exit/exist/, /No/no/, /title/title,/. But +1 to situation specific message. This is not an exception raised in inner loops for control flow. (The reason for some quick and vague exception messages.)
| assert gh.patch_url is None | ||
|
|
||
|
|
||
| def test_validate_issue_number(): |
There was a problem hiding this comment.
This is a "unit" test but it actually makes a call to bpo... maybe this should be mocked as well (or it may not be necessary all together).
There was a problem hiding this comment.
My preference is to mock the call to b.p.o.
Mariatta
left a comment
There was a problem hiding this comment.
Thanks for the PR! I have a few comments, mostly just nitpicky :)
I think the new failure description is a little too long. Perhaps it should be a separate status check?
| STATUS_CONTEXT = "bedevere/issue-number" | ||
| # Try to keep descriptions at or below 50 characters, else GitHub's CSS will truncate it. | ||
| _FAILURE_DESCRIPTION = 'No issue # in title or "skip issue" label found' | ||
| _FAILURE_DESCRIPTION = 'Issue does not exit, No issue # in title or "skip issue" label found' |
There was a problem hiding this comment.
Hmm, this might be too long as a status check message.
I'm thinking it can be a separate status check, maybe "bedevere/valid-issue"? @brettcannon, what do you think?
| target_url=url) | ||
|
|
||
| def validate_issue_number(issue_number): | ||
| """Validate that the issue number exists on bpo""" |
There was a problem hiding this comment.
The docstring should end with a period :)
| urllib.request.urlopen(req) | ||
| return True | ||
| except urllib.error.HTTPError: | ||
| return False No newline at end of file |
| assert gh.patch_url is None | ||
|
|
||
|
|
||
| def test_validate_issue_number(): |
There was a problem hiding this comment.
My preference is to mock the call to b.p.o.
| @@ -1,5 +1,7 @@ | |||
| """Check if a bugs.python.org issue number is specified in the pull request's title.""" | |||
| import re | |||
| import urllib.request | |||
There was a problem hiding this comment.
How about from urllib import error, request instead?
|
Thank you for the review @Mariatta, I made all of the requested changes except for defining a new status check message since you want to get some feedback from Brett. Happy to implement whatever you all decide. |
brettcannon
left a comment
There was a problem hiding this comment.
Thanks for the PR! Let's go with different status check messages based on why the check failed. Otherwise a very minor tweak to a function name.
| description=f"Issue number {issue_number} found", | ||
| target_url=url) | ||
|
|
||
| def validate_issue_number(issue_number): |
There was a problem hiding this comment.
Start with an underscore since this shouldn't be used outside of this module.
| url = f"https://bugs.python.org/issue{issue_number}" | ||
| req = request.Request(url=url, method='HEAD') | ||
| try: | ||
| res = request.urlopen(req) |
There was a problem hiding this comment.
Shouldn’t this use an async request instead of dear old urllib?
|
@levlaz still working on this? |
|
Mariatta was mentioned, but she's out of open source from March 18th to May 9th, 2019 . Be aware she might not get to this until after PyCon US. |
|
Due to this stalling out, I'm closing the PR. |
Add helper function to check if the issue number exists on bpo.
set FAILURE_STATUS in the event that the issue does not exist.
Fix #15