code: 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, options=_decoding_options
      )
  
      backend_client.api.exchangeApiToken(
          X_Neptune_Api_Token=api_token
      ).response().result = auth_tokens
  
      # and
      now = time.time()
      time_mock.time.return_value = now
  
      # and
      session = MagicMock()
      session_mock.return_value = session
      session.token = dict()
  
      # and
      neptune_authenticator = NeptuneAuthenticator(
          api_token, backend_client, False, None
      )
      request = a_request()
  
      # when
      updated_request = neptune_authenticator.apply(request)
  
      # then
      expected_token = {
          "access_token": auth_tokens.accessToken,
          "refresh_token": auth_tokens.refreshToken,
          "expires_in": decoded_access_token["exp"] - now,
      }
  
      expected_auto_refresh_url = (
          "{realm_url}/protocol/openid-connect/token".format(
              realm_url=decoded_access_token["iss"]
          )
      )
  
      session_mock.assert_called_once_with(
          client_id=decoded_access_token["azp"],
          token=expected_token,
          auto_refresh_url=expected_auto_refresh_url,
          auto_refresh_kwargs={
              "client_id": decoded_access_token["azp"]
          },
          token_updater=_no_token_updater,
      )
  
      # and
      self.assertEqual(session, updated_request.auth.session)
  
file_path: neptune-client/tests/unit/neptune/legacy/test_oauth.py
imports: import time
  import unittest
  import jwt
  from mock import MagicMock, patch
  from oauthlib.oauth2 import TokenExpiredError
  from neptune.common.oauth import NeptuneAuth, NeptuneAuthenticator, _decoding_options, _no_token_updater
  from tests.unit.neptune.legacy.http_objects_factory import a_request
  from tests.unit.neptune.legacy.oauth_objects_factory import SECRET, a_refresh_token, an_access_token
label_desc: Use image node_id 1 for calling the TestNeptuneAuthenticator obj's underlying member method code with example usage: obj.test_apply_oauth2_session_to_request(time_mock, session_mock) without return types