Author: tomaz
Date: Sun Apr 10 20:04:29 2011
New Revision: 1090883

URL: http://svn.apache.org/viewvc?rev=1090883&view=rev
Log:
Refactor more stuff into base MockRawResponse class.

Modified:
    incubator/libcloud/trunk/test/__init__.py
    incubator/libcloud/trunk/test/storage/test_cloudfiles.py

Modified: incubator/libcloud/trunk/test/__init__.py
URL: 
http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/__init__.py?rev=1090883&r1=1090882&r2=1090883&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/__init__.py (original)
+++ incubator/libcloud/trunk/test/__init__.py Sun Apr 10 20:04:29 2011
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import httplib
+import random
 
 from cStringIO import StringIO
 from urllib2 import urlparse
@@ -177,11 +178,33 @@ class MockRawResponse(BaseMockHttpObject
 
     def __init__(self):
         super(MockRawResponse, self).__init__()
+        self._data = []
+        self._current_item = 0
+
         self._status = None
         self._response = None
         self._headers = None
         self._reason = None
 
+    def next(self):
+        if self._current_item == len(self._data):
+            raise StopIteration
+
+        value = self._data[self._current_item]
+        self._current_item += 1
+        return value
+
+    def _generate_random_data(self, size):
+        data = []
+        current_size = 0
+        while current_size < size:
+            value = str(random.randint(0, 9))
+            value_size = len(value)
+            data.append(value)
+            current_size += value_size
+
+        return data
+
     @property
     def response(self):
         return self._get_response_if_not_availale()

Modified: incubator/libcloud/trunk/test/storage/test_cloudfiles.py
URL: 
http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/storage/test_cloudfiles.py?rev=1090883&r1=1090882&r2=1090883&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/storage/test_cloudfiles.py (original)
+++ incubator/libcloud/trunk/test/storage/test_cloudfiles.py Sun Apr 10 
20:04:29 2011
@@ -515,30 +515,6 @@ class CloudFilesMockRawResponse(MockRawR
     fixtures = StorageFileFixtures('cloudfiles')
     base_headers = { 'content-type': 'application/json; charset=UTF-8'}
 
-    def __init__(self, *args, **kwargs):
-        super(CloudFilesMockRawResponse, self).__init__(*args, **kwargs)
-        self._data = []
-        self._current_item = 0
-
-    def next(self):
-        if self._current_item == len(self._data):
-            raise StopIteration
-
-        value = self._data[self._current_item]
-        self._current_item += 1
-        return value
-
-    def _generate_random_data(self, size):
-        data = []
-        current_size = 0
-        while current_size < size:
-            value = str(random.randint(0, 9))
-            value_size = len(value)
-            data.append(value)
-            current_size += value_size
-
-        return data
-
     def  _v1_MossoCloudFS_foo_bar_container_foo_test_upload(
         self, method, url, body, headers):
         # test_object_upload_success


Reply via email to