Skip to content

Commit

Permalink
fix(Authorization): Fix authorization to get from result
Browse files Browse the repository at this point in the history
  • Loading branch information
ehdsouza committed Oct 15, 2018
1 parent c314d88 commit 332db35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions test/unit/test_authorization_v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding: utf-8
import responses
import watson_developer_cloud


@responses.activate
def test_request_token():
url = 'https://stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api'
responses.add(responses.GET,
url=url,
body=b'mocked token',
status=200)
authorization = watson_developer_cloud.AuthorizationV1(username='xxx',
password='yyy')
authorization.get_token(url=watson_developer_cloud.SpeechToTextV1.default_url)
assert responses.calls[0].request.url == url
assert responses.calls[0].response.content == 'mocked token'
2 changes: 1 addition & 1 deletion watson_developer_cloud/authorization_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def get_token(self, url):
self.url = urlparse.urlunsplit(parsed_url)

response = self.request(method='GET', url='/v1/token?url=' + url)
return response.text
return response.result.text

0 comments on commit 332db35

Please sign in to comment.