Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita99ac0e

Browse files
committed
Add remove_assignees method
Add a convenience method to unassign a list of users from an issue.Closessigmavirus24#711
1 parent8e226d7 commita99ac0e

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

‎src/github3/issues/issue.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,27 @@ def pull_request(self):
329329
json=self._json(self._get(pull_request_url),200)
330330
returnself._instance_or_null(pulls.PullRequest,json)
331331

332+
@requires_auth
333+
defremove_assignees(self,users):
334+
"""Unassign ``users`` from this issue.
335+
336+
This is a shortcut for :meth:`~github3.issues.issue.Issue.edit`.
337+
338+
:param users:
339+
users or usernames to unassign this issue from
340+
:type users:
341+
list of :class:`~github3.users.User`
342+
:type users:
343+
list of str
344+
:returns:
345+
True if successful, False otherwise
346+
:rtype:
347+
bool
348+
"""
349+
usernames= {getattr(user,'login',user)foruserinusers}
350+
assignees=list({a.loginforainself.assignees}-usernames)
351+
returnself.edit(assignees=assignees)
352+
332353
@requires_auth
333354
defremove_label(self,name):
334355
"""Remove label ``name`` from this issue.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "User-Agent": ["github3.py/1.1.0"], "Accept-Charset": ["utf-8"], "Connection": ["keep-alive"], "Content-Type": ["application/json"], "Authorization": ["token <AUTH_TOKEN>"]}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/issues/711"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA+1YbW/iRhD+K66lVm0UY4wdSCgQ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P2YNWjzmazis8Ulalgigc4u/0velGv7jSuXM+zKLOgW7Eks5ZcLEStzOpayXgYoDhBcHNpJ5GCjuUn+PlrNp53FG3JgRDmP9b+cC5dr9FYGcQ4JCpu5/OtRnMm7bw5G5gGxxEwpiyvHwOz85EJiIyR8zYYNE7yh5aNOi17sU7jDqIaBDiRuRHBwpgSZLxx/f/Jon4r7IJeTKXlZ9sKm7xMIon/0Yl7ugzS2TOgO9NmW5x3hbZIv7IgfFquHLjCu1VMVyvPuI5+oN+WZemPnSs6O7vftqgvPy//s/lX9PCiFvTDTR3okQ0N/HJ2tivs98W4v7KMrWl9NLdKtin2tl1ZV0o/zevx8zchJQr2JBMAAA==", "encoding": "utf-8"}, "headers": {"X-XSS-Protection": ["1; mode=block"], "Content-Security-Policy": ["default-src 'none'"], "Access-Control-Expose-Headers": ["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"], "Transfer-Encoding": ["chunked"], "Last-Modified": ["Fri, 03 Aug 2018 07:31:39 GMT"], "Access-Control-Allow-Origin": ["*"], "X-Frame-Options": ["deny"], "Status": ["200 OK"], "X-GitHub-Request-Id": ["95AE:3FAE:2C780A7:52C3D04:5B640BE5"], "ETag": ["W/\"b4505c5c6261cbcfd05fc36ec2685139\""], "Date": ["Fri, 03 Aug 2018 08:01:41 GMT"], "X-RateLimit-Remaining": ["4997"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "Server": ["GitHub.com"], "X-OAuth-Scopes": ["public_repo, read:user"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "X-Content-Type-Options": ["nosniff"], "Content-Encoding": ["gzip"], "X-Runtime-rack": ["0.080789"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP"], "X-RateLimit-Limit": ["5000"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Type": ["application/json; charset=utf-8"], "X-Accepted-OAuth-Scopes": ["repo"], "X-RateLimit-Reset": ["1533285098"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/issues/711"}, "recorded_at": "2018-08-03T08:01:41"}, {"request": {"body": {"string": "{\"assignees\": []}", "encoding": "utf-8"}, "headers": {"Content-Length": ["17"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "User-Agent": ["github3.py/1.1.0"], "Accept-Charset": ["utf-8"], "Connection": ["keep-alive"], "Content-Type": ["application/json"], "Authorization": ["token <AUTH_TOKEN>"]}, "method": "PATCH", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/issues/711"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA8VW/W/iNhj+V7xIm7aqIQRSaHOBatNu0n6g3Wn0erpyQk5igq+JHfkDlqL+73vtBAaI9npcT5OIIPb7Pn7er8esHC1yJ3TmSpUy9Dxc0lZG1VzHrYQXniAll56kWYEXVGjZCbx6t9sqK49KqYn0+r7vnDrWlCouqunxkICT45jk8hswtmh5NdjKY7ggjwAOMRWEqdeCX8MBMlm8Im4NBqhzVeR7qdiqzovqQlMn7HTPzi6C4MI/dRhPydSsOaPfb3p/f7h6SG9vqtHDjX89fte+Hr8dwLFMFzERTgiVPXUUVTkB+yuOlrhCiiPNsISzGcIM2R4AFy2Nw8rJeUYZWBeEqAKzTN/TCsO+ObLf67TPut1dEu967z9c5cnnpDP6/Ks/ehgZAniBFRb7TWAXZbtpUHNiwpmCvNte1V6Df7kYBICRiQbFRmsoPtfpBk16+6yfz/++9YznOV8Czj7x3aE6cJS3cQWe9W/KsmNhwHXlcTUnkEEIyzR+RuWXuv4QLeu2gpmXCprGAEkogSDp11NrHIHYkgGnldUWi6hjmQhaKsrZEZnbcQc4LjLM6AM+Eg7cJaBYNfv6IK0buL9EDQ7lu/ZbeaWgC5xUJj2CJIQuIOPHYu4BAKSqSjPQN2ZkIf9UkSlOCzO2M5xL8rgWYSe8+2Qrrow5LwkD85wn9wQmyprCpFolIGDAdJ7/9y5r54LmRCrONvsbyQw7IMeCAHY6xQrwO22/77Z7rt8d+2dhpx8G/kc4T5fpjs2524ZPd9w+D9t+Y5PkXDYwDQut5lxMgRxPqG0FI2DXV28BMOZpNTWDDUtRORzDmBAkCSmk0baYGFVr9G2mWWKcT1GsFWJcmb2N+hUEDknRjAv0p1HByCuHEzZh0VzAN0DfYqYsJk7ukZpTWavlJYqkEpxlwwijuSCzwWRz/y6Xy1bMNVOV5FokxCpbc88GPb9/0Q0Cl3EXlNhV3F1zcTFzrdWlVsU0wUWJoSqDMtegxj/B6xu7XqvlQAkgRMSPnT/8827Q728MCpJSXQzq8zarNZNBffFMHCRIDowZr3Vq4gz/4hIyg2reiMOloH6IPDyMvCZOdAtZTRJSqtqIEokWFKMXxv+/BPXbVhVMMK0otmWFIq+bSJF/TOO+XgeZ7pmwJ9vmUJ6fSu02/VZD+HW5CuAKT7Tdrm7dcUOzYR7Xdc3XkxGdnNwdCurTz+v/o99lHp6dBbO5OwdmZWcGfjk5eSrtd9t5/0IYB9v6m7m1bFG8Q1WBNmiUMq5qvX78F2GbEbsADAAA", "encoding": "utf-8"}, "headers": {"X-XSS-Protection": ["1; mode=block"], "Content-Security-Policy": ["default-src 'none'"], "Access-Control-Expose-Headers": ["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"], "Transfer-Encoding": ["chunked"], "Access-Control-Allow-Origin": ["*"], "X-Frame-Options": ["deny"], "Status": ["200 OK"], "X-GitHub-Request-Id": ["95AE:3FAE:2C780CD:52C3D3D:5B640BE5"], "ETag": ["W/\"d2e139e7445377dc3ca16b5e4bf28495\""], "Date": ["Fri, 03 Aug 2018 08:01:41 GMT"], "X-RateLimit-Remaining": ["4996"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "Server": ["GitHub.com"], "X-OAuth-Scopes": ["public_repo, read:user"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "X-Content-Type-Options": ["nosniff"], "Content-Encoding": ["gzip"], "X-Runtime-rack": ["0.273701"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP"], "X-RateLimit-Limit": ["5000"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Type": ["application/json; charset=utf-8"], "X-Accepted-OAuth-Scopes": [""], "X-RateLimit-Reset": ["1533285098"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/issues/711"}, "recorded_at": "2018-08-03T08:01:41"}], "recorded_with": "betamax/0.8.1"}

‎tests/integration/test_issue.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ def test_reopen(self):
215215

216216
assertreopenedisTrue
217217

218+
deftest_remove_assignees(self):
219+
"""Test the ability to remove assignees from an issue."""
220+
self.auto_login()
221+
cassette_name=self.cassette_name('remove_assignees')
222+
withself.recorder.use_cassette(cassette_name):
223+
issue=self.gh.issue(username='sigmavirus24',
224+
repository='github3.py',
225+
number=711)
226+
unassigned=issue.remove_assignees(['jacquerie'])
227+
228+
assertunassignedisTrue
229+
218230
deftest_remove_label(self):
219231
"""Test the ability to remove a label from an issue."""
220232
self.auto_login()

‎tests/unit/test_issues_issue.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def test_remove_all_labels(self):
7777
"""Verify that removing all labels requires authentication."""
7878
self.assert_requires_auth(self.instance.remove_all_labels)
7979

80+
deftest_remove_assignees(self):
81+
"""Verify that removing assignees requires authentication."""
82+
self.assert_requires_auth(self.instance.remove_assignees)
83+
8084
deftest_remove_label(self):
8185
"""Verify that removing a label requires authentication."""
8286
self.assert_requires_auth(self.instance.remove_label,'enhancement')
@@ -307,6 +311,15 @@ def test_remove_all_labels(self):
307311
assertself.instance.remove_all_labels()== []
308312
replace_labels.assert_called_once_with([])
309313

314+
deftest_remove_assignees(self):
315+
"""Verify the request for removing assignees from an issue."""
316+
self.instance.remove_assignees(['octocat'])
317+
318+
self.session.patch.assert_called_once_with(
319+
url_for(),
320+
data='{"assignees": []}'
321+
)
322+
310323
deftest_remove_label(self):
311324
"""Verify the request for removing a label from an issue."""
312325
self.instance.remove_label('enhancement')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp