def setUp(self):
        super(BotoCognitoIdentityTestCaseBase, self).setUp()
        boto_cognitoidentity.__init__(self.opts)
        del self.opts

        # Set up MagicMock to replace the boto3 session
        # connections keep getting cached from prior tests, can't find the
        # correct context object to clear it. So randomize the cache key, to prevent any
        # cache hits
        conn_parameters['key'] = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(50))

        self.patcher = patch('boto3.session.Session')
        self.addCleanup(self.patcher.stop)
        self.addCleanup(delattr, self, 'patcher')
        mock_session = self.patcher.start()

        session_instance = mock_session.return_value
        self.conn = MagicMock()
        self.addCleanup(delattr, self, 'conn')
        session_instance.client.return_value = self.conn
Example #2
0
    IdentityPoolId="default_pool_id",
    IdentityPoolName="default_pool_name",
    AllowUnauthenticatedIdentities=False,
    DeveloperProviderName="test_provider_default",
)

default_pool_role_ret = dict(IdentityPoolId="default_pool_id")

log = logging.getLogger(__name__)

opts = salt.config.DEFAULT_MINION_OPTS
context = {}
utils = salt.loader.utils(opts, whitelist=["boto3"], context=context)

boto_cognitoidentity.__utils__ = utils
boto_cognitoidentity.__init__(opts)
boto_cognitoidentity.__salt__ = {}


def _has_required_boto():
    """
    Returns True/False boolean depending on if Boto is installed and correct
    version.
    """
    if not HAS_BOTO:
        return False
    elif LooseVersion(boto3.__version__) < LooseVersion(required_boto3_version):
        return False
    else:
        return True
Example #3
0
default_pool_ret = dict(IdentityPoolId='default_pool_id',
                        IdentityPoolName='default_pool_name',
                        AllowUnauthenticatedIdentities=False,
                        DeveloperProviderName='test_provider_default')

default_pool_role_ret = dict(IdentityPoolId='default_pool_id')

log = logging.getLogger(__name__)

opts = salt.config.DEFAULT_MINION_OPTS
context = {}
utils = salt.loader.utils(opts, whitelist=['boto3'], context=context)

boto_cognitoidentity.__utils__ = utils
boto_cognitoidentity.__init__(opts)
boto_cognitoidentity.__salt__ = {}


def _has_required_boto():
    '''
    Returns True/False boolean depending on if Boto is installed and correct
    version.
    '''
    if not HAS_BOTO:
        return False
    elif LooseVersion(boto3.__version__) < LooseVersion(required_boto3_version):
        return False
    else:
        return True
def setup_module():
    pytest.helpers.setup_loader({boto_cognitoidentity: {'__utils__': pytest.utils}})
    boto_cognitoidentity.__init__(pytest.opts)