diff options
Diffstat (limited to 'github3/tests')
-rw-r--r-- | github3/tests/fixtures.py | 36 | ||||
-rw-r--r-- | github3/tests/user_handler_test.py | 34 |
2 files changed, 69 insertions, 1 deletions
diff --git a/github3/tests/fixtures.py b/github3/tests/fixtures.py index 02086f8..5f56753 100644 --- a/github3/tests/fixtures.py +++ b/github3/tests/fixtures.py @@ -117,3 +117,39 @@ GET_SHORT_GISTS = [ "created_at": "2010-04-14T02:15:15Z" } ] +GET_FULL_USER = { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "somehexcode", + "url": "https://api.github.com/users/octocat", + "name": "monalisa octocat", + "company": "GitHub", + "blog": "https://github.com/blog", + "location": "San Francisco", + "email": "octocat@github.com", + "hireable": False, + "bio": "There once was...", + "public_repos": 2, + "public_gists": 1, + "followers": 20, + "following": 0, + "html_url": "https://github.com/octocat", + "created_at": "2008-01-14T04:33:35Z", + "type": "User", + "total_private_repos": 100, + "owned_private_repos": 100, + "private_gists": 81, + "disk_usage": 10000, + "collaborators": 8, + "plan": { + "name": "Medium", + "space": 400, + "collaborators": 10, + "private_repos": 20 + } +} +GET_USER_EMAILS = [ + "octocat@github.com", + "support@github.com" +] diff --git a/github3/tests/user_handler_test.py b/github3/tests/user_handler_test.py index ef57925..b1fd0d0 100644 --- a/github3/tests/user_handler_test.py +++ b/github3/tests/user_handler_test.py @@ -13,8 +13,40 @@ class TestAuthUserHandler(TestCase): """ Test private api about user logged """ def setUp(self): - pass + self.gh = api.Github('test', 'pass') + self.handler = self.gh.users + @patch.object(api.Github, 'get') + def test_get(self, get): + get.return_value = GET_FULL_USER + user = self.handler.get() + self.assertIsInstance(user, AuthUser) + get.assert_called_with('user') + self.assertEquals(len(user), len(GET_FULL_USER)) + + @patch.object(api.Github, 'get') + def test_get_emails(self, get): + get.return_value = GET_USER_EMAILS + emails = self.handler.get_emails() + get.assert_called_with('user/emails') + self.assertEquals(emails, GET_USER_EMAILS) + + @patch.object(api.Github, 'post') + def test_create_emails(self, post): + post.return_value = GET_USER_EMAILS + emails = self.handler.create_emails(*GET_USER_EMAILS) + post.assert_called_with('user/emails', data=GET_USER_EMAILS) + self.assertEquals(emails, GET_USER_EMAILS) + + @patch.object(api.Github, 'delete') + def test_delete_emails(self, delete): + response = delete.return_value + response.return_value = '' + response.status_code = 204 + emails = self.handler.delete_emails(*GET_USER_EMAILS) + delete.assert_called_with('user/emails', data=GET_USER_EMAILS, + method='delete') + self.assertTrue(emails) class TestUserHandler(TestCase): """ Test public api about users """ |