Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: boto/tests/cb_test_harnass.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « boto/tests/__init__.py ('k') | boto/tests/devpay_s3.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: boto/tests/cb_test_harnass.py
diff --git a/boto/tests/cb_test_harnass.py b/boto/tests/cb_test_harnass.py
deleted file mode 100644
index 9f4f1c5c823d08f028f413b8f282b0840f3c13b0..0000000000000000000000000000000000000000
--- a/boto/tests/cb_test_harnass.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2010 Google Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish, dis-
-# tribute, sublicense, and/or sell copies of the Software, and to permit
-# persons to whom the Software is furnished to do so, subject to the fol-
-# lowing conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
-# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-
-"""
-Test harnass that allows us to raise exceptions, change file content,
-and record the byte transfer callback sequence, to test various resumable
-upload and download cases. The 'call' method of this harnass can be passed
-as the 'cb' parameter to boto.s3.Key.send_file() and boto.s3.Key.get_file(),
-allowing testing of various file upload/download conditions.
-"""
-
-import socket
-
-
-class CallbackTestHarnass(object):
-
- def __init__(self, fail_after_n_bytes=0, num_times_to_fail=1,
- exception=socket.error('mock socket error', 0),
- fp_to_change=None, fp_change_pos=None):
- self.fail_after_n_bytes = fail_after_n_bytes
- self.num_times_to_fail = num_times_to_fail
- self.exception = exception
- # If fp_to_change and fp_change_pos are specified, 3 bytes will be
- # written at that position just before the first exception is thrown.
- self.fp_to_change = fp_to_change
- self.fp_change_pos = fp_change_pos
- self.num_failures = 0
- self.transferred_seq_before_first_failure = []
- self.transferred_seq_after_first_failure = []
-
- def call(self, total_bytes_transferred, unused_total_size):
- """
- To use this test harnass, pass the 'call' method of the instantiated
- object as the cb param to the set_contents_from_file() or
- get_contents_to_file() call.
- """
- # Record transfer sequence to allow verification.
- if self.num_failures:
- self.transferred_seq_after_first_failure.append(
- total_bytes_transferred)
- else:
- self.transferred_seq_before_first_failure.append(
- total_bytes_transferred)
- if (total_bytes_transferred >= self.fail_after_n_bytes and
- self.num_failures < self.num_times_to_fail):
- self.num_failures += 1
- if self.fp_to_change and self.fp_change_pos is not None:
- cur_pos = self.fp_to_change.tell()
- self.fp_to_change.seek(self.fp_change_pos)
- self.fp_to_change.write('abc')
- self.fp_to_change.seek(cur_pos)
- self.called = True
- raise self.exception
« no previous file with comments | « boto/tests/__init__.py ('k') | boto/tests/devpay_s3.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698