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

Commit9ac4cd9

Browse files
committed
A couple more tests.
Some new behaviour in github3.issues.Issue.add_labels for those using it.
1 parent5453e82 commit9ac4cd9

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

‎HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ History/Changelog
7373
return the same information. In the next version, the former will be
7474
removed.
7575

76+
- ``github3.issues.Issue.add_labels`` now returns the list of Labels on the
77+
issue instead of a boolean.
78+
7679
- Now we won't get spurious GitHubErrors on 404s, only on other expected
7780
errors whilst accessing the json in a response. All methods that return an
7881
object can now *actually* return None if it gets a 404 instead of just

‎github3/issues.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,11 @@ def add_labels(self, *args):
216216
"""Add labels to this issue.
217217
218218
:param str args: (required), names of the labels you wish to add
219-
:returns:bool
219+
:returns:list of :class:`Label`\ s
220220
"""
221221
url=self._build_url('labels',base_url=self._api)
222-
json=self._json(self._post(url,data=args),
223-
status_code=200)
224-
returnTrueifjsonelseFalse
222+
json=self._json(self._post(url,data=args),200)
223+
return [Label(l,self)forlinjson]ifjsonelse []
225224

226225
@requires_auth
227226
defassign(self,login):

‎tests/test_issues.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
importgithub3
22
importdatetime
33
fromtests.utilsimportBaseCase,load,expect
4+
frommockimportpatch
45

56

67
classTestLabel(BaseCase):
@@ -114,7 +115,7 @@ def test_update(self):
114115
self.not_called()
115116

116117
expect(self.m.update('foo','closed',':sparkles:',
117-
'2013-12-31TZ23:59:59Z')).is_True()
118+
'2013-12-31T23:59:59Z')).is_True()
118119
self.mock_assertions()
119120

120121

@@ -131,3 +132,50 @@ def setUp(self):
131132

132133
deftest_repr(self):
133134
expect(repr(self.i))=='<Issue [sigmavirus24/github3.py #1]>'
135+
136+
deftest_add_labels(self):
137+
self.response('label',200,_iter=True)
138+
self.post(self.api+'/labels')
139+
self.conf= {'data':'["enhancement"]'}
140+
141+
withexpect.githuberror():
142+
self.i.add_labels('foo')
143+
144+
self.not_called()
145+
self.login()
146+
labels=self.i.add_labels('enhancement')
147+
expect(labels)!= []
148+
expect(labels[0]).isinstance(github3.issues.Label)
149+
self.mock_assertions()
150+
151+
deftest_assign(self):
152+
withexpect.githuberror():
153+
self.i.assign('foo')
154+
155+
self.not_called()
156+
self.login()
157+
158+
withpatch.object(github3.issues.Issue,'edit')ased:
159+
ed.return_value=True
160+
expect(self.i.assign('sigmavirus24')).is_True()
161+
n=self.i.milestone.numberifself.i.milestoneelseNone
162+
ed.assert_called_once_with(
163+
self.i.title,self.i.body,'sigmavirus24',self.i.state,n,
164+
self.i.labels
165+
)
166+
167+
deftest_close(self):
168+
withexpect.githuberror():
169+
self.i.close()
170+
171+
self.not_called()
172+
self.login()
173+
174+
withpatch.object(github3.issues.Issue,'edit')ased:
175+
ed.return_value=True
176+
expect(self.i.close()).is_True()
177+
u=self.i.assignee.loginifself.i.assigneeelse''
178+
n=self.i.milestone.numberifself.i.milestoneelseNone
179+
ed.assert_called_once_with(
180+
self.i.title,self.i.body,u,self.i.state,n,self.i.labels
181+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp