Skip to content

Instantly share code, notes, and snippets.

@atharvai
Created October 16, 2020 13:28
Show Gist options
  • Save atharvai/d3af52e473857e4dd91bc588d0b1ece9 to your computer and use it in GitHub Desktop.
Save atharvai/d3af52e473857e4dd91bc588d0b1ece9 to your computer and use it in GitHub Desktop.
import botocore
from botocore.exceptions import ClientError
from mock import patch
import boto3
from util import get_credentials
orig = botocore.client.BaseClient._make_api_call
def mock_get_cluster_credentials(self, operation_name, kwarg):
if operation_name == 'GetClusterCredentials':
return {"DbUser": "abc", "DbPassword":"abc"}
return orig(self, operation_name, kwarg)
def get_redshift()
with patch('botocore.client.BaseClient._make_api_call', new=mock_make_api_call):
# Should return actual result
o = get_credentials(mocked_rs_client,'host','port')
# Should return mocked exception
assert 'DbUser' in o
assert 'DbPassword' in o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment