Skip to content

Instantly share code, notes, and snippets.

@obernardocosta
Created January 28, 2020 18:52
Show Gist options
  • Save obernardocosta/c0ac1fb49c535afe23b2f01779ebf248 to your computer and use it in GitHub Desktop.
Save obernardocosta/c0ac1fb49c535afe23b2f01779ebf248 to your computer and use it in GitHub Desktop.
boto3 Hard Mock

Boto3 Hard Mock

Start Mock

boto3_resource = boto3.resource

def boto3_mock_resource(service_name, region_name):
  return boto3_resource(
                        service_name=service_name,
                        region_name=region_name,
                        endpoint_url='http://localhost:8000')
                        
boto3.resource = boto3_mock_resource
sys.modules['boto3'] = boto3

Cleaning

def tearDownModule():
  print('Cleaning up transformacao_entidade')
  boto3.resource = boto3_resource
  sys.modules['boto3'] = boto3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment