Skip to content

Commit 5f6189b

Browse files
Migrate Asset.test_str to tests/unit
Created json/asset_example for test_repo_repo
1 parent d7a2907 commit 5f6189b

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

tests/test_repos.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ def __init__(self, methodName='runTest'):
1212
self.api = ("https://api.github.com/repos/sigmavirus24/github3.py/"
1313
"releases/assets/37945")
1414

15-
def test_repr(self):
16-
assert repr(self.asset) == '<Asset [github3.py-0.7.1.tar.gz]>'
17-
1815
@pytest.mark.xfail
1916
def test_download(self):
2017
headers = {'content-disposition': 'filename=foo'}

tests/unit/json/asset_example

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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",
15+
"id": 1,
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+
}
32+
}

tests/unit/test_repos_repo.py

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

1314
from . import helper
1415

16+
asset_url_for = helper.create_url_helper(
17+
'https://api.github.com/repos/octocat/Hello-World/releases/assets/1'
18+
)
1519
comment_url_for = helper.create_url_helper(
1620
'https://api.github.com/repos/octocat/Hello-World/comments/1'
1721
)
@@ -32,6 +36,9 @@
3236
'https://api.github.com/repos/octocat/Hello-World'
3337
)
3438

39+
get_asset_example_data = helper.create_example_data_helper(
40+
'asset_example'
41+
)
3542
get_repo_example_data = helper.create_example_data_helper(
3643
'repos_repo_example'
3744
)
@@ -53,6 +60,7 @@
5360
create_file_contents_example_data = helper.create_example_data_helper(
5461
'create_file_contents_example'
5562
)
63+
asset_example_data = get_asset_example_data()
5664
comment_example_data = get_comment_example_data()
5765
commit_example_data = get_commit_example_data()
5866
compare_example_data = get_compare_example_data()
@@ -1864,3 +1872,15 @@ def test_patch(self):
18641872
def test_str(self):
18651873
"""Show that instance string is formatted correctly."""
18661874
assert str(self.instance).startswith('<Comparison')
1875+
1876+
1877+
class TestAsset(helper.UnitHelper):
1878+
1879+
"""Unit test for Asset object."""
1880+
1881+
described_class = Asset
1882+
example_data = asset_example_data
1883+
1884+
def test_str(self):
1885+
"""Show that instance string is formatted correctly."""
1886+
assert str(self.instance).startswith('<Asset ')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy