GAE: testing blob loading with a test bench and web test

I use blobstore with my Google App Engine application and everything works fine on the production server and development server. However, testing with a test bench and webtest does not work ...

In my tests, blob exists, since I can access it like this:

blob = self.blobstore_stub.storage._blobs[key]

When I try to load blob in my tests, for example

response = self.app.get("/blob-download/2")

my blobstore download handler is never called, and I get a 404 error (but the link works on dev or prod servers).

I suspect this is a bug with a test bench or website ...

Any ideas on what I might be doing wrong, or if it is a bug with testbed / webtest, what could be a good job so that I can check this part of my code?


, .

import unittest
from webtest import TestApp
from google.appengine.ext import db, testbed
from google.appengine.api import users
from google.appengine.api import apiproxy_stub_map

class ExampleTests(unittest.TestCase):

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.setup_env(app_id="stv")
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_mail_stub()
        self.testbed.init_blobstore_stub()
        self.app = TestApp(main.application)
        apiproxy_stub_map.apiproxy.GetStub("datastore_v3").Clear()
        self.taskqueue_stub = apiproxy_stub_map.apiproxy.GetStub('taskqueue')
        self.mail_stub = apiproxy_stub_map.apiproxy.GetStub('mail')
        self.blobstore_stub = apiproxy_stub_map.apiproxy.GetStub('blobstore')

   def testBlob(self):
        # create blob using files.blobstore.create
        response = self.app.get("/blob-download/2") # This returns 404
        self.assertEqual(response.body, "content of blob") # This fails

app.yaml:

handlers:
- url: /.*
  script: main.application

main.py:

application = webapp2.WSGIApplication(
    [
     ('/blob-download/([^/]+)?', views.BlobDownload),
    ]
+5
1

main.application app.yaml.

, "/blob-download" app.yaml, - , , main.application.

update: , app.yaml , . . Blobstore -, . , , blob . App Engine , , blob. dev_appserver: http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/tools/dev_appserver_blobstore.py#214.

, , dev_appserver , , , testbed + webtest ( 404, ).

, , , gaedriver: http://code.google.com/p/gaedriver/

+3

All Articles