8000 Merge pull request #531 from itsmemattchung/tests/migrate-repos · kentr/github3.py@a9a20c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9a20c1

Browse files
committed
Merge pull request sigmavirus24#531 from itsmemattchung/tests/migrate-repos
Migrated a few test cases from test_repos_repo.
2 parents d2403cc + bf2800d commit a9a20c1

File tree

6 files changed

+87
-41
lines changed

6 files changed

+87
-41
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA62Yy27rNhCGX8XQto7pa5IjoDjtqu3uLNJNNwYt0RYRSRRIyoYj5N37DynZkg/qS1ggMGyF8/HncIaaYRPJNIoXL7Ppy2w2jkpeiCiOdtJm9WYxqY7RONrWeb5u/2HkruB7qWszX7LBKHUohY7iJsrVTpZg9IeCQtPMl9PXxXQc8T23XK9rnWNcZm1lYsb8QzPx1NoInajSitJOElWwmnnj7/tfF6DtdMsgbIQHF6xKthxvDJhhF4IyW+QXEvzUzuRi8FbluTqAcin61kTsZEmedBRZ7r5IgWXDlM0EfIclfZIjpLGPi3JWDTbQ2LVMiWOwIVqkDwtr7SCL9v+zYVpUygHrjUm0rKxU5eMCB9agKb3jpfzgX6PB2gBC0h6X4qxgLfaIxcfNvVnDKi33PDmSa7RIhNzD2V9EXtiDaI8Vpe3fCApyvbRizdOC0nDLcyM+x5Gb3mKQezBG1t0b/cM0T8VpVzHhj6PNVDnK5UZzfRxtlR5J5Kze8gSxOjrgGBkhXEd/SPtnvRn9/uOvPWUvxr2flFzNXOf8QTIO5RDpxp5cRSA9AYCkd3EM4pB9w/DZ5lOCVOcbpblVtw6N6wIHoIb1f1IsWcGLIOEOAFCmVJgnHQAgaUwt7grt6wt3HMO6/CnrYuOPvHuy5jraE6CVG5zzpRBBHjxBGtadykiHMsnCsB2jYf6b222+C5JK9sBscrUJ4uBFyRykYSbj/j1k16HqiEqMAVSLbbBUYpygVgfut5NJkBMSL0GLrQ/S2TFY03o05+Wu5rsw6gmCXadX9Y5/3CxirufOmQIkVWhaburwQ+7MIaW+dkC+h7n0jDlDXUFyvcy54YBeYeNcUBTyVl1wndgiBmH/P2ApTi/R9Pt2GXNbLjEadj6T/aHf0kO82576nc7+HG07EBQSHYM1v1TcZnRyYaqKaxEiukWwZsNRbE0mkyYT3JXVhdCBGewJQHGdZKgaQ3Q2HQNVT8Gtq9a3JDNF9Z4rngb59gQB0G9jiFZP6O9/hT40SKAD9ImFzIWxqgw7Y8+UPrtUVm5lck/Hcj3dBqDmu5FlIsY8z8eIWisTiThGrU27iIJThHnIE7AMXAP4TiUXCOkgr2vhGQ3znWaiBRqRdM0tGoj5dDZ/mi6eZou32bd49RqvFv9gJXWVDsY8P01nGPY2X8SLOf5oTFWbrIfxQ5Zv09d4uYpnzzQEJ2AbgviGKwZ84lrjp/6+11LQrQEMjcnOhr+dzeL/uP9ozZIcsXQR9PfPub98Ld02hdRMFaJCmdDepJxWuaiOE3g6RfuVqsRM0AMzWpn8wNCX+bfloCBIVF1iP5bL1Tg6cIvaFa/e/sOukDg1fTQ1N2ufplFsdU1dJZ6cj4Hew4N8l+feE6NIsunMfBfXTjd7xj1UIbVW7Q1RibTFDUAlyna2Tthq7ltJcJxRb0gU0z+7lbQLS8WW17ld+3oaK0nRCOSqomASusBS6K6C7rD6zbOPtE4qnSH+O5rqUtgD+sdOjxPRr13aFc2fP/8FVCWqjWcTAAA=", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "repo", "etag": "W/\"946049dee4a9ba3d20f9a485ccaf5444\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4993", "x-served-by": "01d096e6cfe28f8aea352e988c332cd3", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "BCDE0E10:14B62:2735FD71:568B7B45", "access-control-allow-credentials": "true", "last-modified": "Sun, 03 Jan 2016 23:32:32 GMT", "date": "Tue, 05 Jan 2016 08:13:57 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1451983253"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2016-01-05T08:13:57"}, {"request": {"body": {"string": "{\"color\": \"fad8c7\", \"name\": \"fakelabel\"}", "encoding": "utf-8"}, "headers": {"Content-Length": "40", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "POST", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/labels"}, "response": {"body": {"string": "{\"url\":\"https://api.github.com/repos/sigmavirus24/github3.py/labels/fakelabel\",\"name\":\"fakelabel\",\"color\":\"fad8c7\"}", "encoding": "utf-8"}, "headers": {"content-length": "115", "vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "", "etag": "\"9cd3fd440ec5817d5e31c1b4f311bf49\"", "location": "https://api.github.com/repos/sigmavirus24/github3.py/labels/fakelabel", "cache-control": "private, max-age=60, s-maxage=60", "status": "201 Created", "x-ratelimit-remaining": "4992", "x-served-by": "474556b853193c38f1b14328ce2d1b7d", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "x-github-request-id": "BCDE0E10:14B62:2735FDB7:568B7B45", "access-control-allow-credentials": "true", "date": "Tue, 05 Jan 2016 08:13:57 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1451983253"}, "status": {"message": "Created", "code": 201}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/labels"}, "recorded_at": "2016-01-05T08:13:57"}], "recorded_with": "betamax/0.5.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA62Yy27rNhCGX8XQto7pa5IjoDjtqu3uLNJNNwYt0RYRSRRIyoYj5N37DynZkg/qS1ggMGyF8/HncIaaYRPJNIoXL7Ppy2w2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8P01nGPY2X8SLOf5oTFWbrIfxQ5Zv09d4uYpnzzQEJ2AbgviGKwZ84lrjp/6+11LQrQEMjcnOhr+dzeL/uP9ozZIcsXQR9PfPub98Ld02hdRMFaJCmdDepJxWuaiOE3g6RfuVqsRM0AMzWpn8wNCX+bfloCBIVF1iP5bL1Tg6cIvaFa/e/sOukDg1fTQ1N2ufplFsdU1dJZ6cj4Hew4N8l+feE6NIsunMfBfXTjd7xj1UIbVW7Q1RibTFDUAlyna2Tthq7ltJcJxRb0gU0z+7lbQLS8WW17ld+3oaK0nRCOSqomASusBS6K6C7rD6zbOPtE4qnSH+O5rqUtgD+sdOjxPRr13aFc2fP/8FVCWqjWcTAAA=", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "repo", "etag": "W/\"946049dee4a9ba3d20f9a485ccaf5444\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4991", "x-served-by": "173530fed4bbeb1e264b2ed22e8b5c20", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "BCDE0E10:1D25E:127CE5AA:568B7D46", "access-control-allow-credentials": "true", "last-modified": "Sun, 03 Jan 2016 23:32:32 GMT", "date": "Tue, 05 Jan 2016 08:22:30 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1451983253"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2016-01-05T08:22:30"}, {"request": {"body": {"string": "{\"title\": \"foo\"}", "encoding": "utf-8"}, "headers": {"Content-Length": "16", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "POST", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/milestones"}, "response": {"body": {"string": "{\"url\":\"https://api.github.com/repos/sigmavirus24/github3.py/milestones/14\",\"html_url\":\"https://github.com/sigmavirus24/github3.py/milestones/foo\",\"labels_url\":\"https://api.github.com/repos/sigmavirus24/github3.py/milestones/14/labels\",\"id\":1484250,\"number\":14,\"title\":\"foo\",\"description\":null,\"creator\":{\"login\":\"itsmemattchung\",\"id\":7358102,\"avatar_url\":\"https://avatars.githubusercontent.com/u/7358102?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/itsmemattchung\",\"html_url\":\"https://github.com/itsmemattchung\",\"followers_url\":\"https://api.github.com/users/itsmemattchung/followers\",\"following_url\":\"https://api.github.com/users/itsmemattchung/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/itsmemattchung/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/itsmemattchung/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/itsmemattchung/subscriptions\",\"organizations_url\":\"https://api.github.com/users/itsmemattchung/orgs\",\"repos_url\":\"https://api.github.com/users/itsmemattchung/repos\",\"events_url\":\"https://api.github.com/users/itsmemattchung/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/itsmemattchung/received_events\",\"type\":\"User\",\"site_admin\":false},\"open_issues\":0,\"closed_issues\":0,\"state\":\"open\",\"created_at\":\"2016-01-05T08:22:30Z\",\"updated_at\":\"2016-01-05T08:22:30Z\",\"due_on\":null,\"closed_at\":null}", "encoding": "utf-8"}, "headers": {"content-length": "1401", "vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "", "etag": "\"da3cfaf3328f31c65acc153503ee958c\"", "location": "https://api.github.com/repos/sigmavirus24/github3.py/milestones/14", "cache-control": "private, max-age=60, s-maxage=60", "status": "201 Created", "x-ratelimit-remaining": "4990", "x-served-by": "d594a23ec74671eba905bf91ef329026", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "x-github-request-id": "BCDE0E10:1D25E:127CE5CB:568B7D46", "access-control-allow-credentials": "true", "date": "Tue, 05 Jan 2016 08:22:30 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1451983253"}, "status": {"message": "Created", "code": 201}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/milestones"}, "recorded_at": "2016-01-05T08:22:31"}], "recorded_with": "betamax/0.5.0"}

tests/integration/test_repos_repo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,26 @@ def test_create_key(self):
300300
key = repository.create_key(**data)
301301
assert isinstance(key, github3.users.Key)
302302

303+
def test_create_label(self):
304+
"""Test the ability to create a label on a repository."""
305+
self.token_login()
306+
cassette_name = self.cassette_name('create_label')
307+
with self.recorder.use_cassette(cassette_name):
308+
repository = self.gh.repository('sigmavirus24', 'github3.py')
309+
label = repository.create_label('fakelabel', 'fad8c7')
310+
311+
assert isinstance(label, github3.issues.label.Label)
312+
313+
def test_create_milestone(self):
314+
"""Test the ability to create a milestone on a repository."""
315+
self.token_login()
316+
cassette_name = self.cassette_name('create_milestone')
317+
with self.recorder.use_cassette(cassette_name):
318+
repository = self.gh.repository('sigmavirus24', 'github3.py')
319+
milestone = repository.create_milestone('foo')
320+
321+
assert isinstance(milestone, github3.issues.milestone.Milestone)
322+
303323
def test_create_release(self):
304324
"""Test the ability to create a release on a repository."""
305325
self.token_login()

tests/test_repos.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,6 @@ def setUp(self):
1515
self.repo = repos.Repository(self.repo.as_dict(), self.g)
1616
self.api = 'https://api.github.com/repos/sigmavirus24/github3.py/'
1717

18-
def test_create_key(self):
19-
self.response('key', 201)
20-
self.post(self.api + 'keys')
21-
self.conf = {'data': {'key': 'ssh-rsa foobarbogus',
22-
'title': 'Fake key'}}
23-
24-
self.assertRaises(github3.GitHubError, self.repo.create_key,
25-
**self.conf['data'])
26-
27-
self.login()
28-
assert isinstance(self.repo.create_key(**self.conf['data']),
29-
github3.users.Key)
30-
self.mock_assertions()
31-
32-
def test_create_label(self):
33-
self.response('label', 201)
34-
self.post(self.api + 'labels')
35-
self.conf = {'data': {'name': 'foo', 'color': 'f00f00'}}
36-
37-
self.assertRaises(github3.GitHubError, self.repo.create_label,
38-
**self.conf['data'])
39-
40-
self.login()
41-
assert isinstance(self.repo.create_label(**self.conf['data']),
42-
github3.issues.label.Label)
43-
self.mock_assertions()
44-
45-
def test_create_milestone(self):
46-
self.response('milestone', 201)
47-
self.post(self.api + 'milestones')
48-
self.conf = {'data': {'title': 'foo'}}
49-
50-
self.assertRaises(github3.GitHubError, self.repo.create_milestone,
51-
**self.conf['data'])
52-
53-
self.login()
54-
assert isinstance(self.repo.create_milestone('foo'),
55-
github3.issues.milestone.Milestone)
56-
self.mock_assertions()
57-
5818
def test_create_pull(self):
5919
self.response('pull', 201)
6020
self.post(self.api + 'pulls')

tests/unit/test_repos_repo.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,70 @@ def test_create_key_requires_a_valid_title_and_key(self):
170170

171171
assert self.session.post.called is False
172172

173+
def test_create_label(self):
174+
"""Verify the request for creating a label."""
175+
data = {
176+
'name': 'foo',
177+
'color': 'fafafa'
178+
}
179+
self.instance.create_label(**data)
180+
self.post_called_with(
181+
url_for('labels'),
182+
data=data
183+
)
184+
185+
def test_create_label_required_name(self):
186+
"""Verify the request for creating a label."""
187+
data = {
188+
'name': '',
189+
'color': 'fafafa'
190+
}
191+
self.instance.create_label(**data)
192+
assert self.session.post.called is False
193+
194+
def test_create_label_required_color(self):
195+
"""Verify the request for creating a label."""
196+
data = {
197+
'name': 'foo',
198+
'color': ''
199+
}
200+
self.instance.create_label(**data)
201+
assert self.session.post.called is False
202+
203+
def test_create_label_required_name_and_color(self):
204+
"""Verify the request for creating a label."""
205+
data = {
206+
'name': '',
207+
'color': ''
208+
}
209+
self.instance.create_label(**data)
210+
assert self.session.post.called is False
211+
212+
def test_create_milestone(self):
213+
"""Verify the request for creating a milestone."""
214+
data = {
215+
'title': 'foo'
216+
}
217+
self.instance.create_milestone(**data)
218+
self.post_called_with(
219+
url_for('milestones'),
220+
data=data
221+
)
222+
223+
def test_create_milestone_accepted_state(self):
224+
"""Verify the request for creating a milestone."""
225+
data = {
226+
'title': 'foo',
227+
'state': 'in_progress'
228+
}
229+
self.instance.create_milestone(**data)
230+
self.post_called_with(
231+
url_for('milestones'),
232+
data={
233+
'title': 'foo'
234+
}
235+
)
236+
173237
def test_create_ref(self):
174238
"""Verify the request to create a reference."""
175239
self.instance.create_ref('refs/heads/foo', 'my-fake-sha')

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ commands =
5353

5454
[testenv:readme]
5555
deps =
56-
readme
56+
readme_renderer
5757
commands =
5858
python setup.py check -r -s
5959

0 commit comments

Comments
 (0)
0