Skip to content

Commit b751769

Browse files
committed
Add unit test for User#email_addresses
Remove test in old-style tests Fix docstring and repr
1 parent 56f8b03 commit b751769

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

github3/users.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _update_attributes(self, email):
122122
self.primary = email.get('primary')
123123

124124
def _repr(self):
125-
return '<UserEmail [{0}]>'.format(self.email)
125+
return '<Email [{0}]>'.format(self.email)
126126

127127
def __str__(self):
128128
return self.email
@@ -264,8 +264,7 @@ def delete_email_addresses(self, addresses=[]):
264264

265265
@requires_auth
266266
def email_addresses(self, number=-1):
267-
"""Iterate over each email address in the authenticated
268-
user's account.
267+
"""Iterate over each email address in the authenticated user's account.
269268
270269
:param int number: (optional), number of email addresses to return.
271270
Default: -1, returns all of them

tests/test_users.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,6 @@ def test_str(self):
2323
assert self.plan.is_free()
2424

2525

26-
class TestUserEmail(BaseCase):
27-
def __init__(self, methodName='runTest'):
28-
super(TestUserEmail, self).__init__(methodName)
29-
self.useremail = github3.users.UserEmail({
30-
'email': 'test@email.com',
31-
'verified': True,
32-
'primary': True,
33-
})
34-
35-
def test_str(self):
36-
assert str(self.useremail) == self.useremail.email
37-
assert repr(self.useremail) == '<UserEmail [test@email.com]>'
38-
39-
4026
class TestUser(BaseCase):
4127
def __init__(self, methodName='runTest'):
4228
super(TestUser, self).__init__(methodName)

tests/unit/test_users.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ class TestUserIterators(UnitIteratorHelper):
8686
described_class = github3.users.User
8787
example_data = example_data.copy()
8888

89+
def test_email_addresses(self):
90+
"""Verify the request to retrive a user's email addresses."""
91+
i = self.instance.email_addresses()
92+
self.get_next(i)
93+
94+
self.session.get.assert_called_once_with(
95+
url_for('user/emails'),
96+
params={'per_page': 100},
97+
headers={}
98+
)
99+
89100
def test_events(self):
90101
"""Test the request to retrieve a user's events."""
91102
i = self.instance.events()

0 commit comments

Comments
 (0)