rdodev
rdodev

Reputation: 3202

Unit testing GAE Blobstore (with nose)

We're using nose with nose-gae for unit testing our controllers and models. We now have code that hits the blob store and files API. We are having a hard time testing those due to lack of testing proxies/mocks. Is there a good way to unit tests these services or lacking unit testing is there a way to automated acceptance test those APIs? TIA.

Upvotes: 1

Views: 126

Answers (2)

Kirill Levin
Kirill Levin

Reputation: 103

I had the same question so I dug into the nosegae code, and then into the actual testbed code.

All you need to do is set nosegae_blobstore = True where you're setting up all the other stubs. This sets up a dict-backed blobstore stub.

Upvotes: 0

mentat
mentat

Reputation: 198

Try something like this for the blobstorage tests:

from google.appengine.ext import testbed
from google.appengine.api.blobstore import file_blob_storage

testbed.Testbed()
testbed._blob_storage = file_blob_storage.FileBlobStorage('/tmp/', 'testing')
testbed.init_blobstore_stub()
testbed.init_files_stub()

Works well in my tests (though I don't use nose, I use webtest).

Upvotes: 4

Related Questions