forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_git.py
More file actions
92 lines (70 loc) · 2.77 KB
/
test_git.py
File metadata and controls
92 lines (70 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import github3
from tests.utils import (BaseCase, load)
class TestCommit(BaseCase):
def __init__(self, methodName='runTest'):
super(TestCommit, self).__init__(methodName)
self.commit = github3.git.Commit(load('commit'))
def test_repr(self):
assert repr(self.commit).startswith('<Commit')
def test_author_as_User(self):
u = self.commit.author_as_User()
assert isinstance(u, github3.users.User)
def test_committer_as_User(self):
u = self.commit.committer_as_User()
assert isinstance(u, github3.users.User)
class TestReference(BaseCase):
def __init__(self, methodName='runTest'):
super(TestReference, self).__init__(methodName)
self.ref = github3.git.Reference(load('ref'))
self.api = ('https://api.github.com/repos/sigmavirus24/github3.py/'
'git/refs/heads/master')
def setUp(self):
super(TestReference, self).setUp()
self.ref = github3.git.Reference(self.ref.to_json(), self.g)
def test_repr(self):
assert repr(self.ref).startswith('<Reference')
assert repr(self.ref.object).startswith('<Git Object')
def test_delete(self):
self.response('', 204)
self.delete(self.api)
self.assertRaises(github3.GitHubError, self.ref.delete)
self.not_called()
self.login()
assert self.ref.delete()
self.mock_assertions()
def test_update(self):
self.response('ref', 200)
self.patch(self.api)
self.conf = {
'data': {
'sha': 'fakesha',
'force': True,
}
}
self.assertRaises(github3.GitHubError, self.ref.update, 'fake')
self.not_called()
self.login()
assert self.ref.update('fakesha', True)
self.mock_assertions()
self.response('', 404)
assert self.ref.update('fakesha', True) is False
self.mock_assertions()
class TestTree(BaseCase):
def __init__(self, methodName='runTest'):
super(TestTree, self).__init__(methodName)
self.tree = github3.git.Tree(load('tree'))
self.api = ('https://api.github.com/repos/sigmavirus24/github3.py/git/'
'trees/75b347329e3fc87ac78895ca1be58daff78872a1')
def setUp(self):
super(TestTree, self).setUp()
self.tree = github3.git.Tree(self.tree.to_json(), self.g)
def test_recurse(self):
self.response('tree', 200)
self.get(self.api)
self.conf = {'params': {'recursive': '1'}}
t = self.tree.recurse()
assert isinstance(t, github3.git.Tree)
assert repr(t).startswith('<Tree')
self.mock_assertions()
assert isinstance(t.tree[0], github3.git.Hash)
assert repr(t.tree[0]).startswith('<Hash')