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

Commitdc84d3e

Browse files
committed
Start working on github3.pulls
1 parentd35587b commitdc84d3e

File tree

3 files changed

+131
-7
lines changed

3 files changed

+131
-7
lines changed

‎github3/pulls.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,6 @@ def diff(self):
181181
headers={'Accept':'application/vnd.github.diff'})
182182
returnresp.contentifself._boolean(resp,200,404)elseNone
183183

184-
defis_mergeable(self):
185-
"""Checks to see if the pull request can be merged by GitHub.
186-
187-
:returns: bool
188-
"""
189-
returnself.mergeable
190-
191184
defis_merged(self):
192185
"""Checks to see if the pull request was merged.
193186

‎tests/test_notifications.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
importgithub3
2+
importdatetime
3+
fromtests.utilsimportBaseCase,load,expect
4+
5+
6+
classTestThread(BaseCase):
7+
def__init__(self,methodName='runTest'):
8+
super(TestThread,self).__init__(methodName)
9+
self.thread=github3.notifications.Thread(load('notification'))
10+
self.api= ("https://api.github.com/notifications/threads/6169361")
11+
12+
deftest_last_read_at(self):
13+
json=self.thread.to_json().copy()
14+
json['last_read_at']='2013-12-31T23:59:59Z'
15+
t=github3.notifications.Thread(json)
16+
expect(t.last_read_at).isinstance(datetime.datetime)
17+
18+
deftest_repr(self):
19+
expect(repr(self.thread))=='<Thread [{0}]>'.format(
20+
self.thread.subject.get('title'))
21+
22+
deftest_delete_subscription(self):
23+
self.response('',204)
24+
self.delete(self.api+'/subscription')
25+
26+
expect(self.thread.delete_subscription()).is_True()
27+
self.mock_assertions()
28+
29+
deftest_is_unread(self):
30+
expect(self.thread.is_unread())==self.thread.unread
31+
32+
deftest_mark(self):
33+
self.response('',205)
34+
self.patch(self.api)
35+
self.conf= {'data': {'read':True}}
36+
37+
expect(self.thread.mark()).is_True()
38+
self.mock_assertions()
39+
40+
deftest_set_subscription(self):
41+
self.response('subscription')
42+
self.put(self.api+'/subscription')
43+
self.conf= {'data': {'subscribed':True,'ignored':False}}
44+
45+
expect(self.thread.set_subscription(True,False)).isinstance(
46+
github3.notifications.Subscription)
47+
self.mock_assertions()
48+
49+
deftest_subscription(self):
50+
self.response('subscription')
51+
self.get(self.api+'/subscription')
52+
53+
expect(self.thread.subscription()).isinstance(
54+
github3.notifications.Subscription)
55+
self.mock_assertions()
56+
57+
58+
classTestSubscription(BaseCase):
59+
def__init__(self,methodName='runTest'):
60+
super(TestSubscription,self).__init__(methodName)
61+
self.subscription=github3.notifications.Subscription(
62+
load('subscription'))
63+
self.api= ("https://api.github.com/notifications/threads/5864188/"
64+
"subscription")
65+
66+
deftest_repr(self):
67+
expect(repr(self.subscription))=='<Subscription [True]>'
68+
69+
deftest_delete(self):
70+
self.response('',204)
71+
self.delete(self.api)
72+
73+
expect(self.subscription.delete()).is_True()
74+
self.mock_assertions()
75+
76+
deftest_is_ignored(self):
77+
expect(self.subscription.is_ignored())==self.subscription.ignored
78+
79+
deftest_is_subscription(self):
80+
subbed=self.subscription.is_subscribed()
81+
expect(subbed)==self.subscription.subscribed
82+
83+
deftest_set(self):
84+
self.response('subscription')
85+
self.put(self.api)
86+
self.conf= {'data': {'subscribed':True,'ignored':False}}
87+
88+
expect(self.subscription.set(True,False)).is_None()
89+
self.mock_assertions()

‎tests/test_pulls.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
importgithub3
2+
frommockimportpatch
3+
fromtests.utilsimportBaseCase,load,expect
4+
5+
6+
classTestPullRequest(BaseCase):
7+
def__init__(self,methodName='runTest'):
8+
super(TestPullRequest,self).__init__(methodName)
9+
self.pull=github3.pulls.PullRequest(load('pull'))
10+
self.api= ("https://api.github.com/repos/sigmavirus24/github3.py/"
11+
"pulls/18")
12+
13+
defsetUp(self):
14+
super(TestPullRequest,self).setUp()
15+
self.pull=github3.pulls.PullRequest(self.pull.to_json(),self.g)
16+
17+
deftest_repr(self):
18+
expect(repr(self.pull).startswith('<Pull Request'))
19+
20+
deftest_close(self):
21+
withexpect.githuberror():
22+
self.pull.close()
23+
24+
self.login()
25+
26+
withpatch.object(github3.pulls.PullRequest,'update')asup:
27+
up.return_value=True
28+
expect(self.pull.close()).is_True()
29+
up.assert_called_once_with(
30+
self.pull.title,self.pull.body,'closed')
31+
32+
deftest_diff(self):
33+
self.response('archive',200)
34+
self.get(self.api)
35+
self.conf= {
36+
'headers': {
37+
'Accept':'application/vnd.github.diff'
38+
}
39+
}
40+
41+
expect(self.pull.diff())!=''
42+
self.mock_assertions()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp