code: def test_swift_session_by_user_key():
      def mock_init(
          self,
          session=None,
          swift_storage_url=None,
          swift_auth_token=None,
          swift_auth_v1_url=None,
          swift_user=None,
          swift_key=None,
      ):
          self._creds = {
              "SWIFT_STORAGE_URL": "foo",
              "SWIFT_AUTH_TOKEN": "bar",
          }
  
      with mock.patch(
          "rasterio.session.SwiftSession.__init__", new=mock_init
      ):
          swift_session = SwiftSession(
              swift_auth_v1_url="foo", swift_user="bar", swift_key="key"
          )
          assert swift_session._creds
          assert (
              swift_session.get_credential_options()[
                  "SWIFT_STORAGE_URL"
              ]
              == "foo"
          )
          assert (
              swift_session.get_credential_options()["SWIFT_AUTH_TOKEN"]
              == "bar"
          )
  
imports: from unittest import mock
  import pytest
  from rasterio.session import DummySession, AWSSession, Session, OSSSession, GSSession, SwiftSession, AzureSession, parse_bool
label_desc: Use image node_id 27 for calling a global function with example usage: test_swift_session_by_user_key() without return types