Test the github utility get_github_user_token method.
(self)
| 110 | |
| 111 | @responses.activate |
| 112 | def test_get_github_user_token(self): |
| 113 | """Test the github utility get_github_user_token method.""" |
| 114 | data = {'access_token': self.user_oauth_token, 'scope': 'read:user,user:email'} |
| 115 | params = { |
| 116 | 'code': self.callback_code, |
| 117 | 'client_id': settings.GITHUB_CLIENT_ID, |
| 118 | 'client_secret': settings.GITHUB_CLIENT_SECRET, |
| 119 | } |
| 120 | params = urlencode(params, quote_via=quote_plus) |
| 121 | url = settings.GITHUB_TOKEN_URL + '?' + params |
| 122 | responses.add(responses.GET, settings.GITHUB_TOKEN_URL, json=data, headers=JSON_HEADER, status=200) |
| 123 | responses.add(responses.GET, settings.GITHUB_TOKEN_URL, json={}, headers=JSON_HEADER, status=200) |
| 124 | result = get_github_user_token(self.callback_code) |
| 125 | result_no_token = get_github_user_token(self.callback_code) |
| 126 | |
| 127 | assert responses.calls[0].request.url == url |
| 128 | assert responses.calls[1].request.url == url |
| 129 | assert result == self.user_oauth_token |
| 130 | assert result_no_token is None |
| 131 | |
| 132 | @responses.activate |
| 133 | def test_get_github_user_data(self): |
nothing calls this directly
no test coverage detected