Skip to content

Commit fe9bcf6

Browse files
committed
Fix passing None to urlparse.
Also fix test in test_repos.
1 parent 14a7990 commit fe9bcf6

9 files changed

Lines changed: 21 additions & 20 deletions

File tree

github3/gists.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def __init__(self, data, session=None):
6767
self.description = data.get('description', '')
6868

6969
# e.g. https://api.github.com/gists/1
70-
self._api = data.get('url')
71-
#self._api = self._build_url('gists', str(self._id))
70+
self._api = data.get('url', '')
7271

7372
#: URL of this gist at Github, e.g., https://gist.github.com/1
7473
self.html_url = data.get('html_url')

github3/git.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Blob(GitHubObject):
1717
"""The :class:`Blob <Blob>` object."""
1818
def __init__(self, blob):
1919
super(Blob, self).__init__(blob)
20-
self._api = blob.get('url')
20+
self._api = blob.get('url', '')
2121

2222
#: Raw content of the blob.
2323
self.content = blob.get('content').encode()
@@ -48,7 +48,7 @@ def __init__(self, data, session=None):
4848
super(GitData, self).__init__(data, session)
4949
#: SHA of the object
5050
self.sha = data.get('sha')
51-
self._api = data.get('url')
51+
self._api = data.get('url', '')
5252

5353

5454
class Commit(BaseCommit):
@@ -89,7 +89,7 @@ class Reference(GitHubCore):
8989
"""
9090
def __init__(self, ref, session=None):
9191
super(Reference, self).__init__(ref, session)
92-
self._api = ref.get('url')
92+
self._api = ref.get('url', '')
9393
#: The reference path, e.g., refs/heads/sc/featureA
9494
self.ref = ref.get('ref')
9595
#: :class:`GitObject <GitObject>` the reference points to

github3/issues.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Label(GitHubCore):
1818
exists in a repository."""
1919
def __init__(self, label, session=None):
2020
super(Label, self).__init__(label, session)
21-
self._api = label.get('url')
21+
self._api = label.get('url', '')
2222
#: Color of the label, e.g., 626262
2323
self.color = label.get('color')
2424
#: Name of the label, e.g., 'bug'
@@ -64,7 +64,7 @@ class Milestone(GitHubCore):
6464
"""
6565
def __init__(self, mile, session=None):
6666
super(Milestone, self).__init__(mile, session)
67-
self._api = mile.get('url')
67+
self._api = mile.get('url', '')
6868
#: Identifying number associated with milestone.
6969
self.number = mile.get('number')
7070
#: State of the milestone, e.g., open or closed.
@@ -141,7 +141,7 @@ class Issue(GitHubCore):
141141
"""
142142
def __init__(self, issue, session=None):
143143
super(Issue, self).__init__(issue, session)
144-
self._api = issue.get('url')
144+
self._api = issue.get('url', '')
145145
#: :class:`User <github3.users.User>` representing the user the issue
146146
# was assigned to.
147147
self.assignee = None
@@ -377,7 +377,7 @@ def __init__(self, event, issue=None):
377377
self.event = event.get('event')
378378
#: SHA of the commit.
379379
self.commit_id = event.get('commit_id')
380-
self._api = event.get('url')
380+
self._api = event.get('url', '')
381381

382382
#: :class:`Issue <Issue>` where this comment was made.
383383
self.issue = issue

github3/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __init__(self, comment, session):
157157
#: datetime object representing when the comment was updated.
158158
self.updated_at = self._strptime(comment.get('updated_at'))
159159

160-
self._api = comment.get('url')
160+
self._api = comment.get('url', '')
161161
self.links = comment.get('_links')
162162
#: The url of this comment at GitHub
163163
self.html_url = ''
@@ -204,7 +204,7 @@ class BaseCommit(GitHubCore):
204204
"""
205205
def __init__(self, commit, session):
206206
super(BaseCommit, self).__init__(commit, session)
207-
self._api = commit.get('url')
207+
self._api = commit.get('url', '')
208208
#: SHA of this commit.
209209
self.sha = commit.get('sha')
210210
#: Commit message

github3/orgs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class Team(GitHubCore):
1818
def __init__(self, team, session=None):
1919
super(Team, self).__init__(team, session)
20-
self._api = team.get('url')
20+
self._api = team.get('url', '')
2121
#: This team's name.
2222
self.name = team.get('name')
2323
#: Unique ID of the team.

github3/pulls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class PullRequest(GitHubCore):
7575
"""The :class:`PullRequest <PullRequest>` object."""
7676
def __init__(self, pull, session=None):
7777
super(PullRequest, self).__init__(pull, session)
78-
self._api = pull.get('url')
78+
self._api = pull.get('url', '')
7979
#: Base of the merge
8080
self.base = PullDestination(pull.get('base'), 'Base')
8181
#: Body of the pull request message

github3/repos.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(self, repo, session=None):
8787
#: ``datetime`` object representing the last time the repository was
8888
# updated.
8989
self.updated_at = self._strptime(repo.get('updated_at'))
90-
self._api = repo.get('url')
90+
self._api = repo.get('url', '')
9191

9292
# The number of watchers
9393
#: Number of users watching the repository.
@@ -1309,7 +1309,7 @@ class Contents(GitHubObject):
13091309
def __init__(self, content):
13101310
super(Contents, self).__init__(content)
13111311
# links
1312-
self._api = content['_links'].get('self')
1312+
self._api = content['_links'].get('self', '')
13131313
#: Dictionary of links
13141314
self.links = content.get('_links')
13151315

@@ -1361,7 +1361,7 @@ class Download(GitHubCore):
13611361

13621362
def __init__(self, download, session=None):
13631363
super(Download, self).__init__(download, session)
1364-
self._api = download.get('url')
1364+
self._api = download.get('url', '')
13651365
#: URL of the download at GitHub.
13661366
self.html_url = download.get('html_url')
13671367
#: Unique id of the download on GitHub.
@@ -1410,7 +1410,7 @@ class Hook(GitHubCore):
14101410

14111411
def __init__(self, hook, session=None):
14121412
super(Hook, self).__init__(hook, session)
1413-
self._api = hook.get('url')
1413+
self._api = hook.get('url', '')
14141414
#: datetime object representing when this hook was last updated.
14151415
self.updated_at = None
14161416
if hook.get('updated_at'):
@@ -1624,7 +1624,7 @@ class Comparison(GitHubObject):
16241624

16251625
def __init__(self, compare):
16261626
super(Comparison, self).__init__(compare)
1627-
self._api = compare.get('api')
1627+
self._api = compare.get('api', '')
16281628
#: URL to view the comparison at GitHub
16291629
self.html_url = compare.get('html_url')
16301630
#: Permanent link to this comparison.

github3/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Key(GitHubCore):
1717
"""The :class:`Key <Key>` object."""
1818
def __init__(self, key, session=None):
1919
super(Key, self).__init__(key, session)
20-
self._api = key.get('url')
20+
self._api = key.get('url', '')
2121
#: The text of the actual key
2222
self.key = key.get('key')
2323
#: The unique id of the key at GitHub

tests/test_repos.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_contents(self):
123123
expect(contents).isinstance(Contents)
124124

125125
def test_download(self):
126-
download = self.alt_repo.download(310737)
126+
download = self.repo.download(316176)
127127
expect(download).isinstance(Download)
128128

129129
def test_git_commit(self):
@@ -384,6 +384,8 @@ def test_create_key(self):
384384
pass
385385

386386
def test_edit(self):
387+
if not self.auth:
388+
return
387389
old = {'name': self.alt_repo.name,
388390
'description': self.alt_repo.description,
389391
'homepage': self.alt_repo.homepage,

0 commit comments

Comments
 (0)