Testbed unit tests for blobstore file upload API

185 views
Skip to first unread message

re...@el-tramo.be

unread,
Mar 4, 2015, 5:01:37 AM3/4/15
to google-a...@googlegroups.com
Hi,

I'm trying to write a unit test for file uploads in my (Python) API.
I'm using the using the blobstore API to create an upload URL, as follows:
    self.response.write(blobstore.create_upload_url(....))

Everything works fine in production, but when using Testbed, I get the following URL back:
    http://testbed.example.com/_ah/upload/agx0ZXN0YmVkLXRlc3RyGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxgDDA

Uploading to this URL from the test doesn't work, I get a 404. I should have initialized all stubs properly, amongst others:
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_blobstore_stub()
    self.testbed.init_files_stub()

What am I doing wrong? How do I unit test file uploads?

thanks,
Remko

Alex Martelli

unread,
Mar 4, 2015, 11:01:50 AM3/4/15
to google-a...@googlegroups.com
Hi Remko,

technical questions like yours are better sent to Stack Overflow -- the groups are for discussions that would not be welcome on stackoverflow.com per their FAQ.

In this case you're probably able to use the solution already posted at http://stackoverflow.com/questions/8130063/test-function-with-google-app-engine-files-api
so it's probably best not to post your Q there (it would be a duplicate).

If that solution doesn't work, however, then a new stackoverflow Q is indeed appropriate
(specifically referring to that other Q and explaining what problems remain after using the
approach in that Q's accepted and vastly-upvoted answer).  We sponsor and monitor
(among others) the google-app-engine tag on stackoverflow and will do our best to help there, if the existing solution does not meet your very sensible requirements.

`testbed` is unfortunately rather undocumented (sorry!) but that's a longer-term issue for us to fix... not something you should wait for!


Alex


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/4bc5a934-20f9-419a-a990-fa923c5a53b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Baire Adams

unread,
Mar 5, 2015, 4:59:38 PM3/5/15
to google-a...@googlegroups.com
Alex,

Thanks for your response to Remko!

I am facing a similar issue as Remko.  I happily came across your post and followed the link to stackoverflow.  When researching a bit more, it seems the blobstore file API is being deprecated...

Is there no better (read long term) way of doing this than the stackoverflow post suggests?  Probably I am missing something here.

Regards,
Baire
Reply all
Reply to author
Forward
0 new messages