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

Skip to content

Commit e233097

Browse files
authored
Merge pull request sigmavirus24#565 from itsmemattchung/tests/migrate-repos
Removed tests/test_repos.py
2 parents 06bf42c + 3af1269 commit e233097

File tree

5 files changed

+49
-144
lines changed

5 files changed

+49
-144
lines changed

tests/test_repos.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

tests/unit/json/asset_example

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/unit/json/repos_asset_example

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
{
2-
"url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1",
2+
"url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1",
3+
"browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip",
4+
"id": 1,
5+
"name": "example.zip",
6+
"label": "short description",
7+
"state": "uploaded",
8+
"content_type": "application/zip",
9+
"size": 1024,
10+
"download_count": 42,
11+
"created_at": "2013-02-27T19:35:32Z",
12+
"updated_at": "2013-02-27T19:35:32Z",
13+
"uploader": {
14+
"login": "octocat",
315
"id": 1,
4-
"name": "example.zip",
5-
"label": "short description",
6-
"state": "uploaded",
7-
"content_type": "application/zip",
8-
"size": 1024,
9-
"download_count": 42,
10-
"created_at": "2013-02-27T19:35:32Z",
11-
"updated_at": "2013-02-27T19:35:32Z"
16+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
17+
"gravatar_id": "",
18+
"url": "https://api.github.com/users/octocat",
19+
"html_url": "https://github.com/octocat",
20+
"followers_url": "https://api.github.com/users/octocat/followers",
21+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
22+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
23+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
24+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
25+
"organizations_url": "https://api.github.com/users/octocat/orgs",
26+
"repos_url": "https://api.github.com/users/octocat/repos",
27+
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
28+
"received_events_url": "https://api.github.com/users/octocat/received_events",
29+
"type": "User",
30+
"site_admin": false
31+
}
1232
}

tests/unit/test_repos_release.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .helper import (UnitHelper, UnitIteratorHelper, create_url_helper, mock,
44
create_example_data_helper)
55

6+
import github3
67
import json
78
import pytest
89

@@ -140,6 +141,25 @@ def test_download(self):
140141
)
141142
assert stream.called is False
142143

144+
def test_download_with_302(self):
145+
"""Verify the request to download an Asset file."""
146+
with mock.patch.object(github3.models.GitHubCore, '_get') as get:
147+
get.return_value.status_code = 302
148+
get.return_value.headers = {'location': 'https://fakeurl'}
149+
self.instance.download()
150+
data = {
151+
'headers': {
152+
'Content-Type': None,
153+
'Accept': 'application/octet-stream'
154+
},
155+
'stream': True
156+
}
157+
assert get.call_count == 2
158+
get.assert_any_call(
159+
'https://fakeurl',
160+
**data
161+
)
162+
143163
def test_edit_without_label(self):
144164
self.instance.edit('new name')
145165
self.session.patch.assert_called_once_with(

tests/unit/test_repos_repo.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
from base64 import b64encode
77
from github3 import GitHubError
88
from github3.null import NullObject
9-
from github3.repos.release import Asset
109
from github3.repos.repo import (Comparison, Contents, Hook, RepoComment,
1110
RepoCommit, Repository)
1211
from github3.models import GitHubCore
1312

1413
from . import helper
1514

16-
asset_url_for = helper.create_url_helper(
17-
'https://api.github.com/repos/octocat/Hello-World/releases/assets/1'
18-
)
1915
comment_url_for = helper.create_url_helper(
2016
'https://api.github.com/repos/octocat/Hello-World/comments/1'
2117
)
@@ -35,10 +31,6 @@
3531
url_for = helper.create_url_helper(
3632
'https://api.github.com/repos/octocat/Hello-World'
3733
)
38-
39-
get_asset_example_data = helper.create_example_data_helper(
40-
'asset_example'
41-
)
4234
get_repo_example_data = helper.create_example_data_helper(
4335
'repos_repo_example'
4436
)
@@ -60,7 +52,6 @@
6052
create_file_contents_example_data = helper.create_example_data_helper(
6153
'create_file_contents_example'
6254
)
63-
asset_example_data = get_asset_example_data()
6455
comment_example_data = get_comment_example_data()
6556
commit_example_data = get_commit_example_data()
6657
compare_example_data = get_compare_example_data()
@@ -1906,15 +1897,3 @@ def test_patch(self):
19061897
def test_str(self):
19071898
"""Show that instance string is formatted correctly."""
19081899
assert str(self.instance).startswith('<Comparison')
1909-
1910-
1911-
class TestAsset(helper.UnitHelper):
1912-
1913-
"""Unit test for Asset object."""
1914-
1915-
described_class = Asset
1916-
example_data = asset_example_data
1917-
1918-
def test_str(self):
1919-
"""Show that instance string is formatted correctly."""
1920-
assert str(self.instance).startswith('<Asset ')

0 commit comments

Comments
 (0)
0