Created
October 16, 2020 13:28
-
-
Save atharvai/d3af52e473857e4dd91bc588d0b1ece9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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