8000 Start working on github3.pulls · davidmoss/github3.py@dc84d3e · GitHub
[go: up one dir, main page]

Skip to content

Commit dc84d3e

Browse files
committed
Start working on github3.pulls
1 parent d35587b commit dc84d3e

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
return resp.content if self._boolean(resp, 200, 404) else None
183183

184-
def is_mergeable(self):
185-
"""Checks to see if the pull request can be merged by GitHub.
186-
187-
:returns: bool
188-
"""
189-
return self.mergeable
190-
191184
def is_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+
import github3
2+
import datetime
3+
from tests.utils import BaseCase, load, expect
4+
5+
6+
class TestThread(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+
def test_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+
def test_repr(self):
19+
expect(repr(self.thread)) == '<Thread [{0}]>'.format(
20+
self.thread.subject.get('title'))
21+
22+
def test_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+
def test_is_unread(self):
30+
expect(self.thread.is_unread()) == self.thread.unread
31+
32+
def test_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+
def test_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+
def test_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+
class TestSubscription(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+
def test_repr(self):
67+
expect(repr(self.subscription)) == '<Subscription [True]>'
68+
69+
def test_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+
def test_is_ignored(self):
77+
expect(self.subscription.is_ignored()) == self.subscription.ignored
78+
79+
def test_is_subscription(self):
80+
subbed = self.subscription.is_subscribed()
81+
expect(subbed) == self.subscription.subscribed
82+
83+
def test_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+
import github3
2+
from mock import patch
3+
from tests.utils import BaseCase, load, expect
4+
5+
6+
class TestPullRequest(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+
def setUp(self):
14+
super(TestPullRequest, self).setUp()
15+
self.pull = github3.pulls.PullRequest(self.pull.to_json(), self.g)
16+
17+
def test_repr(self):
18+
expect(repr(self.pull).startswith('<Pull Request'))
19+
20+
def test_close(self):
21+
with expect.githuberror():
22+
self.pull.close()
23+
24+
self.login()
25+
26+
with patch.object(github3.pulls.PullRequest, 'update') as up:
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+
def test_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)
0