Kekito が正しいと思います。upload_url に直接 POST することはできません。
ただし、BlobstoreUploadHandler をテストする場合は、次の方法で、通常 blobstore から受信する POST 要求を偽造できます。ハンドラーが /handler にあると仮定します。
import email
...
def test_upload(self):
blob_key = 'abcd'
# The blobstore upload handler receives a multipart form request
# containing uploaded files. But instead of containing the actual
# content, the files contain an 'email' message that has some meta
# information about the file. They also contain a blob-key that is
# the key to get the blob from the blobstore
# see blobstore._get_upload_content
m = email.message.Message()
m.add_header('Content-Type', 'image/png')
m.add_header('Content-Length', '100')
m.add_header('X-AppEngine-Upload-Creation', '2014-03-02 23:04:05.123456')
# This needs to be valie base64 encoded
m.add_header('content-md5', 'd74682ee47c3fffd5dcd749f840fcdd4')
payload = m.as_string()
# The blob-key in the Content-type is important
params = [('file', webtest.forms.Upload('test.png', payload,
'image/png; blob-key='+blob_key))]
self.testapp.post('/handler', params, content_type='blob-key')
ブロブストアのコードを掘り下げて、それを理解しました。重要な点は、ブロブストアが UploadHandler に送信する POST 要求にファイル コンテンツが含まれていないことです。代わりに、ファイルに関するメタデータ (content-type、content-length、upload time、および md5) を含む「電子メール メッセージ」(つまり、電子メールのようにエンコードされた情報) が含まれています。また、ブロブストアからファイルを取得するために使用できるブロブ キーも含まれています。