Skip to content

Commit 8aa3b39

Browse files
authored
Merge pull request #879 from jacquerie/add-unassign-issue
Add mass assign/unassign methods to Issue
2 parents 87af5a1 + a99ac0e commit 8aa3b39

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed

src/github3/issues/issue.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Module containing the Issue logic."""
33
from __future__ import unicode_literals
44

5+
import warnings
56
from json import dumps
67

78
from uritemplate import URITemplate
@@ -67,6 +68,27 @@ def _repr(self):
6768
n=self.number, class_name=self.class_name,
6869
)
6970

71+
@requires_auth
72+
def add_assignees(self, users):
73+
"""Assign ``users`` to this issue.
74+
75+
This is a shortcut for :meth:`~github3.issues.issue.Issue.edit`.
76+
77+
:param users:
78+
users or usernames to assign this issue to
79+
:type users:
80+
list of :class:`~github3.users.User`
81+
:type users:
82+
list of str
83+
:returns:
84+
True if successful, False otherwise
85+
:rtype:
86+
bool
87+
"""
88+
usernames = {getattr(user, 'login', user) for user in users}
89+
assignees = list({a.login for a in self.assignees} | usernames)
90+
return self.edit(assignees=assignees)
91+
7092
@requires_auth
7193
def add_labels(self, *args):
7294
"""Add labels to this issue.
@@ -86,6 +108,10 @@ def add_labels(self, *args):
86108
def assign(self, username):
87109
"""Assign user ``username`` to this issue.
88110
111+
.. deprecated:: 1.2.0
112+
113+
Use :meth:`github3.issues.issue.Issue.add_assignees` instead.
114+
89115
This is a short cut for :meth:`~github3.issues.issue.Issue.edit`.
90116
91117
:param str username:
@@ -95,6 +121,9 @@ def assign(self, username):
95121
:rtype:
96122
bool
97123
"""
124+
warnings.warn(
125+
'This method is deprecated. Please use ``add_assignees`` '
126+
'instead.', DeprecationWarning, stacklevel=2)
98127
if not username:
99128
return False
100129
number = self.milestone.number if self.milestone else None
@@ -300,6 +329,27 @@ def pull_request(self):
300329
json = self._json(self._get(pull_request_url), 200)
301330
return self._instance_or_null(pulls.PullRequest, json)
302331

332+
@requires_auth
333+
def remove_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) for user in users}
350+
assignees = list({a.login for a in self.assignees} - usernames)
351+
return self.edit(assignees=assignees)
352+
303353
@requires_auth
304354
def remove_label(self, name):
305355
"""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": "H4sIAAAAAAAAA8VW/W/iNhj+V7xIm7aqISSkcGSBatPupP1Au9Poelo5IScx4GtiR/6Apaj/+147gQNEez2u0yQiiP2+j5/36zFrR4vciZyFUqWMPA+XtDWnaqGTVsoLT5CSS0/SeYGXVGgZhF6922mVlUel1ER6Pd93zh1rShUX1fR0SMDJcUJy+Q0YO7S8GmztMVyQRwCHmArC1GvBb+AAmSxfEbcGA9SFKvKDVOxU50V1oZkTBZ2Li34Y9v1zh/GMTM2aM/rtpvvnh6uH7PamGj3c+Nfj9+3r8dsBHMt0kRDhRFDZc0dRlROwv+JohSukONIMSzibIcyQ7QFw0dI4rJ2czykD64IQVWA21/e0wrBvjux1g/ZFp7NP4n33rw9XefopDUaffvFHDyNDAC+xwuKwCeyibDcNak5MOVOQd9ur2mvwL5eDEDDmokGx0RqKz3W6QZPeIevn839oPeN5zleAc0h8f6iOHOVtXYFn/Zuy+akw4Lr2uFoQyCCEZRp/TuWXuv4YLeu2hpmXCprGAEkogSDZ11NrHIHYigGntdUWi6gTmQpaKsrZCZnbcwc4LuaY0Qd8Ihy4S0Cxavb1QVo3cH+JGhzLd+239kpBlzitTHoESQldQsZPxTwAAEhVlWagb8zIQv6pIlOcFWZsZziX5HEjwk5099FWXBlzXhIG5jlP7wlMlDWFSbVKQMCA6Tz//C5r54LmRCrOtvtbyYwCkGNBADubYgX4Qdvvue2u63fG/kUU9KLQ/xvO02W2Z/PGbcMnGAedqN2P/L6xSXMuG5iGhVYLLqZAjqfUtoIRsOurt2Cc8KyamsGGpbgcjmFMCJKEFNJoW0KMqjX6NtMsNc7nKNEKMa7M3lb9CgKHZGjGBfrdqGDslcMJm7B4IeAboG8xUxYTp/dILais1fISxVIJzubDGKOFILPBZHv/rlarVsI1U5XkWqTEKltzz4Zdv9fvhKHLuAtK7Crubri4mLnW6lKrYpriosRQlUGZa1DjH+D1Z7teq+VACSBExPfBO/9NJ+z1tgYFyaguBvV529WayaC+eCYOEiQHxozXOjVxhn9wCZlBNW/E4VJQ38UeHsZeEye6haymKSlVbUSJREuK0Qvj/1+C+nWnCiaYVpzYskKRN02kyD+mcV+vg0z3TNiTbXMsz0+ldpd+qyH8ulwFcIUn3m1Xt+64odkwj+u65uvJiM7O7o4F9fHHzf/R/2Qenp0Fs7k/B2ZlbwZ+Ojt7Ku13u3n/QhhH2/qbubVsUbxjVfmslElV6/Xjv5qtd9IADAAA", "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": ["Thu, 02 Aug 2018 23:09:19 GMT"], "Access-Control-Allow-Origin": ["*"], "X-Frame-Options": ["deny"], "Status": ["200 OK"], "X-GitHub-Request-Id": ["A2E6:3FAE:2C29574:52316EC:5B6404DA"], "ETag": ["W/\"5b4dd8dd9fd32bdbfc73353b8813f599\""], "Date": ["Fri, 03 Aug 2018 07:31:38 GMT"], "X-RateLimit-Remaining": ["4999"], "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.104248"], "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-03T07:31:38"}, {"request": {"body": {"string": "{\"assignees\": [\"jacquerie\"]}", "encoding": "utf-8"}, "headers": {"Content-Length": ["28"], "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": "H4sIAAAAAAAAA+1YbW/iRhD+K66lVm0UY4wdSCgQXdWrdB8gdyppTg0ntLYX2MTe9e0L1EH57zdr82IsSMJL1Q89CQSsZ559dnae2R3mpuKR2TQnUiaiadsoIZUxkRPlVwIW2xwnTNiCjGM0JVyJmmfnT91KktpECIWF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Mm7bw5G5gGxxEwpiyvHwOz85EJiIyR8zYYNE7yh5aNOi17sU7jDqIaBDiRuRHBwpgSZLxx/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"], "Access-Control-Allow-Origin": ["*"], "X-Frame-Options": ["deny"], "Status": ["200 OK"], "X-GitHub-Request-Id": ["A2E6:3FAE:2C295A6:5231732:5B6404DA"], "ETag": ["W/\"b4505c5c6261cbcfd05fc36ec2685139\""], "Date": ["Fri, 03 Aug 2018 07:31:39 GMT"], "X-RateLimit-Remaining": ["4998"], "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.706423"], "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-03T07:31:39"}], "recorded_with": "betamax/0.8.1"}
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+K66lVm0UY4wdSCgQXdWrdB8gdyppTg0ntLYX2MTe9e0L1EH57zdr82IsSMJL1Q89CQSsZ559dnae2R3mpuKR2TQnUiaiadsoIZUxkRPlVwIW2xwnTNiCjGM0JVyJmmfnT91KktpECIWF3XAc89zMTIlkPB0eDgk4EfJxJI7AKNCyc7C5TVGMnwEc1hRjKk8Fv4QDZDw9IW4OBqgTGUelUBR25037QkKzWXMvLq4878o5NykL8VCPmd3fb+t/fu49hXe3affp1rnpf6re9N+3YVqqYh9zswk7e25KIiMM9j1mzFBqSGYoigTMTQ1EjSwHwEUJ7TA3IzYmFKxjjGWM6Fg9khTBcz1lo16rXrjuJolP9b8+96LgIah1H9453aeuJoCmSCJeToJsUFQXCapnDBiVEPcsV5W9wL+etj3AGPMFSrZaTfGlTNdowi6zfjn+ZesRiyI2A5wy8U1RbZnKXrkCz/w7oeNDYcB1bjM5wRBBWJZO/DERr2X9NlqZ2xw0LyQkjQYSsAUch/tTWzgCsRkFTvOstmSIyhcBJ4kkjB4QuQ13gGN8jCh5QgfCgbsAlKya7b/IzA3c31INtsU795vbCSdTFKQ6PBwHmEwh4odilgAAUqaJFvStlizEn0g8RGGsZTtCkcDPyyJsNu+/ZDsutTlLMAXziAWPGBSVmYJSs0qAwWCt/QcUfFWYE10XtPjcS6d2Wd0u+67X7X/wuu/ar8m+tlP2OfwRqi/yfVnxRcu91L5yPFzpZYhjVL7GOkrha5jTqbuAWSwMhyh7DbWvqtee+yt67XsaNRe5bJSCNyl5qU8BYv6u0K2X3LwQl+UFxzgEeK+zuAzxXaG7O4ty0P+vCoUDNiYRFpJROEOpiqJ1lwIXd/jBMZy/4RBJCGat6jSsat1y3L5z0aw1mp7zN2SpSsINm0urCi+3X200XafpXmmbIGJiAZPPgpScMD6EAsECkl2XYILeTe89GPssTIf6KIShVtLpw1USGwLjWOj7v4/1zX/RA4wUDbTzueEraVAm9bNVhxBjmCQ0RowbH3Sn0LKTzoAOaGvC4ROg7xCVGSYKHg05ISLvKK6NlpCc0XGnhYwJx6P2YNWjzmazis8Ulalgigc4u/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/dRhPydSs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-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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ class TestIssue(IntegrationHelper):
1111

1212
"""Integration tests for methods on the Issue class."""
1313

14+
def test_add_assignees(self):
15+
"""Test the ability to add assignees to an issue."""
16+
self.auto_login()
17+
cassette_name = self.cassette_name('add_assignees')
18+
with self.recorder.use_cassette(cassette_name):
19+
issue = self.gh.issue(username='sigmavirus24',
20+
repository='github3.py',
21+
number=711)
22+
assigned = issue.add_assignees(['jacquerie'])
23+
24+
assert assigned is True
25+
1426
def test_add_labels(self):
1527
"""Test the ability to add a label to an issue."""
1628
self.auto_login()
@@ -203,6 +215,18 @@ def test_reopen(self):
203215

204216
assert reopened is True
205217

218+
def test_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+
with self.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+
assert unassigned is True
229+
206230
def test_remove_label(self):
207231
"""Test the ability to remove a label from an issue."""
208232
self.auto_login()

tests/unit/test_issues_issue.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class TestIssueRequiresAuth(helper.UnitRequiresAuthenticationHelper):
4444
def after_setup(self):
4545
self.session.has_auth.return_value = False
4646

47+
def test_add_assignees(self):
48+
"""Verify that adding assignees requires authentication."""
49+
self.assert_requires_auth(self.instance.add_assignees)
50+
4751
def test_add_labels(self):
4852
"""Verify that adding a label requires authentication."""
4953
self.assert_requires_auth(self.instance.add_labels, 'enhancement')
@@ -73,6 +77,10 @@ def test_remove_all_labels(self):
7377
"""Verify that removing all labels requires authentication."""
7478
self.assert_requires_auth(self.instance.remove_all_labels)
7579

80+
def test_remove_assignees(self):
81+
"""Verify that removing assignees requires authentication."""
82+
self.assert_requires_auth(self.instance.remove_assignees)
83+
7684
def test_remove_label(self):
7785
"""Verify that removing a label requires authentication."""
7886
self.assert_requires_auth(self.instance.remove_label, 'enhancement')
@@ -92,6 +100,15 @@ class TestIssue(helper.UnitHelper):
92100
described_class = github3.issues.Issue
93101
example_data = get_issue_example_data()
94102

103+
def test_add_assignees(self):
104+
"""Verify the request for adding assignees to an issue."""
105+
self.instance.add_assignees(['jacquerie'])
106+
107+
self.session.patch.assert_called_with(
108+
url_for(),
109+
data='{"assignees": ["jacquerie"]}'
110+
)
111+
95112
def test_add_labels(self):
96113
"""Verify the request for adding a label."""
97114
self.instance.add_labels('enhancement')
@@ -294,6 +311,15 @@ def test_remove_all_labels(self):
294311
assert self.instance.remove_all_labels() == []
295312
replace_labels.assert_called_once_with([])
296313

314+
def test_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+
297323
def test_remove_label(self):
298324
"""Verify the request for removing a label from an issue."""
299325
self.instance.remove_label('enhancement')

0 commit comments

Comments
 (0)