Created
March 9, 2021 13:05
-
-
Save domjancik/fff637b63792d782a5f8712ac711ce6f to your computer and use it in GitHub Desktop.
Mock a single function boto3 / moto
This file contains hidden or 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
# Useful for filling in unimplemented moto https://github.com/spulec/moto functions for instance | |
import botocore.client | |
original_api_call = botocore.client.BaseClient._make_api_call | |
def mock_api_call(self, operation_name, api_params): | |
if operation_name == 'ListAliases': | |
return { | |
"Aliases": [] | |
} | |
return original_api_call(self, operation_name, api_params) | |
# ... | |
class TestCase(unittest.TestCase): | |
# ... | |
@patch('botocore.client.BaseClient._make_api_call', new=mock_api_call) | |
def test_function(self): | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment