Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Fixes tests to now look for to_jwt (#12)
Browse files Browse the repository at this point in the history
* Fixes tests to now look for to_jwt

* Python 3 tweak
  • Loading branch information
Craig Dennis committed Feb 24, 2019
1 parent bb7d08e commit 607520d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion browser_calls_flask/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_token():
capability.allow_client_incoming('customer')

# Generate the capability token
token = capability.to_jwt().decode('utf-8')
token = capability.to_jwt()

return jsonify({'token': token})

Expand Down
8 changes: 4 additions & 4 deletions tests/views_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TwilioTokenTests(BaseTest):
def test_get_token_for_customer_by_default(self):
# Given
mock_capability = MagicMock()
mock_capability.generate.return_value = 'abc123'
mock_capability.to_jwt.return_value = 'abc123'

# When
with patch('browser_calls_flask.views.ClientCapabilityToken', return_value=mock_capability) as mock:
Expand All @@ -68,13 +68,13 @@ def test_get_token_for_customer_by_default(self):
# arguments and that the view returned the correct response
self.assertTrue(mock_capability.allow_client_outgoing.called)
mock_capability.allow_client_incoming.assert_called_once_with('customer')
self.assertTrue(mock_capability.generate.called)
self.assertTrue(mock_capability.to_jwt.called)
self.assertEqual({"token": "abc123"}, json.loads(response.data.decode("utf-8")))

def test_get_token_for_agent_if_referrer_is_dashboard(self):
# Given
mock_capability = MagicMock()
mock_capability.generate.return_value = 'abc123'
mock_capability.to_jwt.return_value = 'abc123'

# When
with patch('browser_calls_flask.views.ClientCapabilityToken', return_value=mock_capability) as mock:
Expand All @@ -83,7 +83,7 @@ def test_get_token_for_agent_if_referrer_is_dashboard(self):
# Then
self.assertTrue(mock_capability.allow_client_outgoing.called)
mock_capability.allow_client_incoming.assert_called_once_with('support_agent')
self.assertTrue(mock_capability.generate.called)
self.assertTrue(mock_capability.to_jwt.called)
self.assertEqual({"token": "abc123"}, json.loads(response.data.decode("utf-8")))


Expand Down

0 comments on commit 607520d

Please sign in to comment.