Closed
Description
When using _get_paged
with the pullrequest.comments
property, query parameters are not supported.
Desired query: https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPOSITORY/pullrequests/PR_ID/comments?q=deleted=false
Actual query: https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPOSITORY/pullrequests/PR_ID/comments
Desired result: All Comment
objects where deleted
== False
Actual result: All Comment
objects.
Steps to reproduce:
# set up initial state
cloud = Cloud(username=USERNAME, password=APP_PASSWORD, cloud=True)
workspace = cloud.workspaces.get(WORKSPACE)
repository = cloud.repositories.get(WORKSPACE, REPOSITORY)
pull_request = repository.pullrequests.get(id=PULL_REQUEST_ID)
# add 6 comments to target PR, delete 3 comments
(steps TBA; I did this manually inside the PR)
# call the original function and save the result
comments = list(pull_request.comments())
# print status of found comments. Should be mix of "True" and "False," 3 of each
[print(comment.data["deleted"]) for comment in comments]
True
True
True
False
False
False
### adding the feature and verifying functionality
# patch atlassian.bitbucket.cloud.repositories.pullRequests.PullRequest:comments to properly handle query parameters
# code changes follow the implementation of PullRequests.each, which already supports a query string
def comments(q=None):
params = {}
if q is not None:
params["q"] = q
for comment in pull_request._get_paged("comments", params=params):
yield Comment(comment, **pull_request._new_session_args)
# reimport module and run the same function again, passing in a value for q:
comments = list(pull_request.comments(q="deleted=false"))
# Final output:
[print(comment.data["deleted"]) for comment in comments]
False
False
False
Metadata
Metadata
Assignees
Labels
No labels