forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_git.py
More file actions
181 lines (132 loc) · 5.08 KB
/
Copy pathtest_git.py
File metadata and controls
181 lines (132 loc) · 5.08 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
from base import BaseTest, expect, expect_str
import github3
from github3.git import (Commit, Blob, Reference, Tag, Tree, Hash, GitObject,
GitData)
class TestGit(BaseTest):
def setUp(self):
super(TestGit, self).setUp()
self.todor = self.g.repository(self.sigm, self.todo)
self.gh3r = self.g.repository(self.sigm, 'github3.py')
class TestBlob(BaseTest):
def __init__(self, methodName='runTest'):
super(TestBlob, self).__init__(methodName)
self.r = self.g.repository(self.sigm, self.todo)
self.blob = self.r.blob('f737918b90118a6aea991f89f444b150a2360393')
def test_blob(self):
expect(self.blob).isinstance(Blob)
expect_str(repr(self.blob))
def test_content(self):
expect_str(self.blob.content)
def test_decoded(self):
expect_str(self.blob.decoded)
def test_encoding(self):
expect_str(self.blob.encoding)
def test_sha(self):
expect_str(self.blob.sha)
def test_size(self):
expect(self.blob.size) >= 0
class TestCommit(BaseTest):
def __init__(self, methodName='runTest'):
super(TestCommit, self).__init__(methodName)
r = self.g.repository(self.sigm, self.todo)
self.commit = r.git_commit('8b0704374914f03a54b89d938de1c09d5831824e')
def test_commit(self):
expect(self.commit).isinstance(Commit)
expect_str(repr(self.commit))
def test_author(self):
expect(self.commit.author).is_not_None()
def test_committer(self):
expect(self.commit.author).is_not_None()
def test_tree(self):
expect(self.commit.tree).isinstance(Tree)
def test_message(self):
expect_str(self.commit.message)
def test_parents(self):
expect(self.commit.parents).isinstance(list)
self.expect_list_of_class(self.commit.parents, dict)
def test_sha(self):
expect_str(self.commit.sha)
class TestTag(BaseTest):
def __init__(self, methodName='runTest'):
super(TestTag, self).__init__(methodName)
r = self.g.repository(self.sigm, 'github3.py')
self.tag = r.tag('495404cbf4918f46a428b268104de37893dad449')
def test_tag(self):
expect(self.tag).isinstance(Tag)
expect_str(repr(self.tag))
def test_message(self):
expect_str(self.tag.message)
def test_object(self):
expect(self.tag.object).isinstance(GitObject)
def test_tagname(self):
expect_str(self.tag.tag)
def test_tagger(self):
expect(self.tag.tagger).isinstance(dict)
def test_sha(self):
expect_str(self.tag.sha)
class TestTreeHash(BaseTest):
def __init__(self, methodName='runTest'):
super(TestTreeHash, self).__init__(methodName)
r = self.g.repository(self.sigm, self.todo)
self.tree = r.tree('31e862095dffa60744f1ce16a431ea040381f053')
self.hashes = self.tree.tree
self.hash = self.hashes[0]
def test_tree(self):
expect(self.tree).isinstance(Tree)
expect_str(repr(self.tree))
def test_tree_sha(self):
expect_str(self.tree.sha)
def test_tree_recurse(self):
expect(self.tree.recurse()).isinstance(Tree)
def test_hash(self):
for h in self.hashes:
expect(h).isinstance(Hash)
expect_str(repr(h))
def test_hash_mode(self):
expect_str(self.hash.mode)
def test_hash_path(self):
expect_str(self.hash.path)
def test_hash_size(self):
expect(self.hash.size) >= 0
def test_hash_type(self):
expect_str(self.hash.type)
def test_hash_url(self):
expect_str(self.hash.url)
class TestReference(BaseTest):
def __init__(self, methodName='runTest'):
super(TestReference, self).__init__(methodName)
r = self.g.repository(self.sigm, self.todo)
self.ref = r.ref('heads/development')
def test_reference(self):
expect(self.ref).isinstance(Reference)
expect_str(repr(self.ref))
def test_object(self):
expect(self.ref.object).isinstance(GitObject)
expect_str(repr(self.ref.object))
def test_ref(self):
expect_str(self.ref.ref)
def test_requires_auth(self):
with expect.raises(github3.GitHubError):
self.ref.delete()
self.ref.update('31e862095dffa60744f1ce16a431ea040381f053')
def test_with_auth(self):
if not self.auth:
return
r = self._g.repository(self.gh3py, self.test_repo)
ref = r.create_ref('refs/tags/test_refs',
'499faa66a0f56235ee55bf295bac2f2f3c3f0a04')
expect(ref.update(
'499faa66a0f56235ee55bf295bac2f2f3c3f0a04'
)).isinstance(bool)
expect(ref.delete()).is_True()
class TestGitData(BaseTest):
def setUp(self):
json = {'sha': 'fakesha', 'url': 'http://www.example.com'}
self.gitdata = GitData(json)
def test_gitdata(self):
expect(self.gitdata).isinstance(GitData)
expect_str(repr(self.gitdata))
expect(repr(self.gitdata)) != ''
def test_sha(self):
expect_str(self.gitdata.sha)
expect(self.gitdata.sha) == 'fakesha'