如何模拟图片上传到谷歌应用引擎blobstore [英] how to simulate image upload to google app engine blobstore
问题描述
我使用create_upload_url将图像上传到GAE blobstore。
$ p $ upload $ url
为了单元测试gae代码,您可以模拟图像上传吗?或者是否应该将图像数据插入我的测试平台并假定上传成功?如果是这样,你如何将图像上传到测试平台?
同意@fredrik关于您在那里测试的内容。
无论如何,如果你正在做一些功能/黑盒/类似的测试,你可以简单地使用 Webtest框架(参见
post
方法),并进行实际的上传,例如 payload = [(fieldname,filename)]
test_app.post(uploadURL,upload_files = payload)
查看 Handler Testing for Python 以获得有关如何初始化上述test_app的详细信息。
I'm uploading images to the GAE blobstore using create_upload_url
uploadURL = blobstore.create_upload_url('/upload')
For the purpose of unit testing the gae code, can you simulate the image upload? OR should I insert the image data in my test bed and assume the upload is successful? If so, how do you upload an image to the test bed?
Agree with @fredrik on what exactly you're testing there.
Anyway, if you're doing some functional/blackbox/similar testing, you could simply use Webtest framework (see post
method) and do the actual upload, e.g.
payload = [(fieldname, filename)]
test_app.post(uploadURL, upload_files=payload)
Have a look at Handler Testing for Python for details on how to initialize the above test_app.
这篇关于如何模拟图片上传到谷歌应用引擎blobstore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!