Skip to content

Instantly share code, notes, and snippets.

@domjancik
Created March 9, 2021 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domjancik/fff637b63792d782a5f8712ac711ce6f to your computer and use it in GitHub Desktop.
Save domjancik/fff637b63792d782a5f8712ac711ce6f to your computer and use it in GitHub Desktop.
Mock a single function boto3 / moto
# 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