| Index: tests/isolateserver_archive_test.py
|
| diff --git a/tests/isolateserver_archive_test.py b/tests/isolateserver_archive_test.py
|
| index d7bbeea4cfec9ab383f96ca92036b249de5b4769..eabdabe60de7c86bf4acd4bcd8d143fa03ea09d5 100755
|
| --- a/tests/isolateserver_archive_test.py
|
| +++ b/tests/isolateserver_archive_test.py
|
| @@ -142,7 +142,7 @@ class IsolateServerTest(unittest.TestCase):
|
| ),
|
| (
|
| 'an_url/',
|
| - {'data': body, 'content_type': content_type},
|
| + {'data': body, 'content_type': content_type, 'retry_50x': False},
|
| StringIO.StringIO('ok'),
|
| ),
|
| ]
|
| @@ -188,6 +188,65 @@ class IsolateServerTest(unittest.TestCase):
|
| finally:
|
| isolateserver_archive.update_files_to_upload = old
|
|
|
| + def test_upload_blobstore_simple(self):
|
| + content = 'blob_content'
|
| + s = hashlib.sha1(content).hexdigest()
|
| + path = 'http://example.com:80/'
|
| + data = [('token', 'foo bar')]
|
| + content_type, body = isolateserver_archive.encode_multipart_formdata(
|
| + data[:], [('content', s, 'blob_content')])
|
| + self._requests = [
|
| + (
|
| + path + 'gen_url?foo#bar',
|
| + {'data': data[:]},
|
| + StringIO.StringIO('an_url/'),
|
| + ),
|
| + (
|
| + 'an_url/',
|
| + {'data': body, 'content_type': content_type, 'retry_50x': False},
|
| + StringIO.StringIO('ok42'),
|
| + ),
|
| + ]
|
| + result = isolateserver_archive.upload_hash_content_to_blobstore(
|
| + path + 'gen_url?foo#bar', data[:], s, content)
|
| + self.assertEqual('ok42', result)
|
| +
|
| + def test_upload_blobstore_retry_500(self):
|
| + content = 'blob_content'
|
| + s = hashlib.sha1(content).hexdigest()
|
| + path = 'http://example.com:80/'
|
| + data = [('token', 'foo bar')]
|
| + content_type, body = isolateserver_archive.encode_multipart_formdata(
|
| + data[:], [('content', s, 'blob_content')])
|
| + self._requests = [
|
| + (
|
| + path + 'gen_url?foo#bar',
|
| + {'data': data[:]},
|
| + StringIO.StringIO('an_url/'),
|
| + ),
|
| + (
|
| + 'an_url/',
|
| + {'data': body, 'content_type': content_type, 'retry_50x': False},
|
| + # Let's say an HTTP 500 was returned.
|
| + None,
|
| + ),
|
| + # In that case, a new url must be generated since the last one may have
|
| + # been "consumed".
|
| + (
|
| + path + 'gen_url?foo#bar',
|
| + {'data': data[:]},
|
| + StringIO.StringIO('an_url/'),
|
| + ),
|
| + (
|
| + 'an_url/',
|
| + {'data': body, 'content_type': content_type, 'retry_50x': False},
|
| + StringIO.StringIO('ok42'),
|
| + ),
|
| + ]
|
| + result = isolateserver_archive.upload_hash_content_to_blobstore(
|
| + path + 'gen_url?foo#bar', data[:], s, content)
|
| + self.assertEqual('ok42', result)
|
| +
|
|
|
| if __name__ == '__main__':
|
| logging.basicConfig(
|
|
|