8000 Merge pull request #660 from mindw/tagger_as_user · omgjlk/github3.py@2a8a0f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a8a0f6

Browse files
authored
Merge pull request sigmavirus24#660 from mindw/tagger_as_user
Support reading tagger as User.
2 parents 7e752ac + 7af6a99 commit 2a8a0f6

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

LATEST_VERSION_NOTES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Unreleased
66
- Add ``Organization#all_events``.
77
- Deprecate ``Organization#events`` in favor of ``Organization#public_events``.
88
- Fix test failtures on windows caused by unclosed file handles.
9+
- Add ``Tag.tagger_as_User`` which attempts to return the tagger as as User.
910

1011
1.0.0a4: 2016-02-19
1112
~~~~~~~~~~~~~~~~~~~

< 8000 code>‎github3/git.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ def _update_attributes(self, tag):
195195
def _repr(self):
196196
return '<Tag [{0}]>'.format(self.tag)
197197

198+
def tagger_as_User(self):
199+
"""Attempt to return the tagger attribute as a
200+
:class:`User <github3.users.User>`. No guarantees are made about the
201+
validity of this object, i.e., having a login or created_at object.
202+
203+
"""
204+
return User(self.tagger, self)
205+
198206

199207
class Tree(GitData):
200208

tests/unit/json/git_tag_example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"tag": "v0.0.1",
3+
"sha": "940bd336248efae0f9ee5bc7b2d5c985887b16ac",
4+
"url": "https://api.github.com/repos/octocat/Hello-World/git/tags/940bd336248efae0f9ee5bc7b2d5c985887b16ac",
5+
"message": "initial version\n",
6+
"tagger": {
7+
"name": "Scott Chacon",
8+
"email": "schacon@gmail.com",
9+
"date": "2014-11-07T22:01:45Z"
10+
},
11+
"object": {
12+
"type": "commit",
13+
"sha": "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c",
14+
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c"
15+
}
16+
}

tests/unit/test_git.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'git/refs/heads/featureA')
1212

1313
get_commit_example_data = create_example_data_helper('commit_example')
14+
get_git_tag_example_data = create_example_data_helper('git_tag_example')
1415
get_reference_example_data = create_example_data_helper('reference_example')
1516

1617

@@ -66,6 +67,22 @@ def test_author_as_User(self):
6667
assert isinstance(user, github3.users.User)
6768

6869

70+
class TestGitTag(UnitHelper):
71+
72+
"""Git Tag unit test."""
73+
74+
described_class = github3.git.Tag
75+
example_data = get_git_tag_example_data()
76+
77+
def test_repr(self):
78+
assert repr(self.instance).startswith('<Tag')
79+
80+
def test_tagger_as_User(self):
81+
"""Show that tagger_as_User() returns instance of User."""
82+
user = self.instance.tagger_as_User()
83+
assert isinstance(user, github3.users.User)
84+
85+
6986
class TestReference(UnitHelper):
7087

7188
"""Reference unit test."""

0 commit comments

Comments
 (0)
0