Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I test a module that depends on boto and an Amazon AWS service?

I'm writing a very small Python ORM around boto.dynamodb.layer2. I would like to write tests for it, but I don't want the tests to actually communicate with AWS, as this would require complicated setup, credentials, network access, etc.

Since I plan to open source the module, including credentials in the source seems like a bad idea since I will get charged for usage, and including credentials in the environment is a pain.

Coupling my tests to the network seems like a bad idea, as it makes the tests run slower, or may cause tests to fail due to network errors or throttling. My goal is not to test boto's DynamoDB interface, or AWS. I just want to test my own code.

I plan to use unittest2 to write the tests and mock to mock out the parts of boto that hit the network, but I've never done this before, so my question boils down to these:

  1. Am I going about this the right way?
  2. Has anyone else done this?
  3. Are there any particular points in the boto.dynamodb interface that would be best to mock out?
like image 733
David Eyk Avatar asked Aug 01 '12 18:08

David Eyk


People also ask

What is Amazon Boto?

Boto is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.

What is Boto module in Python?

Boto is a software development kit (SDK) designed to improve the use of the Python programming language in Amazon Web Services.


1 Answers

I think you have the right approach, you definitely don't want your tests tied up with actual communication with AWS. Mocking the service is definitely the right thing to do here.

like image 139
pcalcao Avatar answered Oct 11 '22 05:10

pcalcao