Skip to content

Commit ecf7ea9

Browse files
committed
Add author attribute to Release objects
The Author data comes from the API and fits nicely into the ShortUser object, so make it happen. A test was added to cover it too. Signed-off-by: Jesse Keating <jkeating@j2solutions.net>
1 parent 3001eb8 commit ecf7ea9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

github3/repos/release.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from .. import utils
99
from .. import models
10+
from .. import users
1011
from ..decorators import requires_auth
1112
from ..exceptions import error_for
1213

@@ -62,6 +63,10 @@ def _update_attributes(self, release):
6263
#: URITemplate to upload an asset with
6364
self.upload_urlt = URITemplate(release['upload_url'])
6465

66+
#: :class:`User <github3.users.ShortUser>` object representing the
67+
#: creator of the release
68+
self.author = users.ShortUser(release['author'])
69+
6570
#: URLs to various attributes
6671
for urltype in ['assets_url', 'html_url', 'tarball_url',
6772
'zipball_url']:

tests/unit/test_repos_release.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from github3.repos.release import Release, Asset
2+
from github3.users import ShortUser
23

34
from .helper import (UnitHelper, UnitIteratorHelper, create_url_helper, mock,
45
create_example_data_helper)
@@ -29,6 +30,10 @@ def test_original_assets(self):
2930
def test_has_upload_urlt(self):
3031
assert self.instance.upload_urlt is not None
3132

33+
def test_has_author(self):
34+
assert self.instance.author is not None
35+
assert isinstance(self.instance.author, ShortUser)
36+
3237
# Method tests
3338
def test_tarball_archive(self):
3439
"""Verify that we generate the correct URL for a tarball archive."""

0 commit comments

Comments
 (0)