justengland / boto-stubber

An example of how to use stubber to unit test boto3 code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aws boto3 patching example

Use boto stubber to stub out responses from the AWS Api, via the python patch.object functionality. Using the Nose testing framework.

Run example client to pull items from public s3 buckets and sts calls.

./read.py

Run unit tests

python3 -m nose

Testing overview

  1. Do a simple test with the s3 client using boto's stubber functionality
  2. Test a complex function that calls multiple AWS API's, by using patching side effects, returned in a serial array function. which may seem simpler, but may be more brittle if the order of the clients calls changes
  3. Test a complex function that calls multiple AWS API's, by using patching side effects, returned with an inline function. which may seem more complex, but may be less brittle if the order of the clients calls changes

References:

About

An example of how to use stubber to unit test boto3 code


Languages

Language:Python 100.0%