Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HubertJaworski committed Oct 27, 2020
1 parent c808baa commit 1f2ea87
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/neptune/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):

self.session = MagicMock()
self.session.token = dict()
self.neptune_auth = NeptuneAuth(self.session)
self.neptune_auth = NeptuneAuth(lambda: self.session)
self.neptune_auth.token_expires_at = time.time() + 60
self.request = a_request()

Expand Down Expand Up @@ -87,11 +87,16 @@ class TestNeptuneAuthenticator(unittest.TestCase):
@patch('neptune.oauth.time')
def test_apply_oauth2_session_to_request(self, time_mock, session_mock):
# given
api_token = MagicMock()
backend_client = MagicMock()

auth_tokens = MagicMock()
auth_tokens.accessToken = an_access_token()
auth_tokens.refreshToken = a_refresh_token()
decoded_access_token = jwt.decode(auth_tokens.accessToken, SECRET)

backend_client.api.exchangeApiToken(X_Neptune_Api_Token=api_token).response().result = auth_tokens

# and
now = time.time()
time_mock.time.return_value = now
Expand All @@ -102,7 +107,7 @@ def test_apply_oauth2_session_to_request(self, time_mock, session_mock):
session.token = dict()

# and
neptune_authenticator = NeptuneAuthenticator(auth_tokens, False, None)
neptune_authenticator = NeptuneAuthenticator(api_token, backend_client, False, None)
request = a_request()

# when
Expand Down

0 comments on commit 1f2ea87

Please sign in to comment.