55import os
66from abc import ABC , abstractmethod
77from time import time
8+ from typing import TYPE_CHECKING
89from unittest import mock
910from unittest .mock import patch
1011from urllib .parse import parse_qs , urlparse
1112
1213import jwt
13- from botocore .awsrequest import AWSRequest
14- from botocore .credentials import Credentials
14+
15+ from snowflake .connector .options import botocore , installed_boto
16+
17+ if TYPE_CHECKING :
18+ from botocore .awsrequest import AWSRequest
1519
1620from snowflake .connector .vendored .requests .exceptions import ConnectTimeout , HTTPError
1721from snowflake .connector .vendored .requests .models import Response
@@ -365,6 +369,8 @@ class FakeAwsEnvironment:
365369 """
366370
367371 def __init__ (self ):
372+ assert installed_boto , "Cannot run test: botocore is not installed"
373+
368374 # Defaults used for generating a token. Can be overriden in individual tests.
369375 self .arn = "arn:aws:sts::123456789:assumed-role/My-Role/i-34afe100cad287fab"
370376 # Path of roles that can be assumed. Empty if no impersonation is allowed.
@@ -374,7 +380,9 @@ def __init__(self):
374380
375381 self .caller_identity = {"Arn" : self .arn }
376382 self .region = "us-east-1"
377- self .credentials = Credentials (access_key = "ak" , secret_key = "sk" )
383+ self .credentials = botocore .credentials .Credentials (
384+ access_key = "ak" , secret_key = "sk"
385+ )
378386 self .instance_document = (
379387 b'{"region": "us-east-1", "instanceId": "i-1234567890abcdef0"}'
380388 )
0 commit comments