libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1103357 - in /incubator/libcloud/trunk: libcloud/storage/base.py libcloud/storage/drivers/cloudfiles.py test/storage/test_cloudfiles.py test/storage/test_s3.py
Date Sun, 15 May 2011 12:56:49 GMT
Author: tomaz
Date: Sun May 15 12:56:48 2011
New Revision: 1103357

URL: http://svn.apache.org/viewvc?rev=1103357&view=rev
Log:
Make get_meta_data and extension method and update affected tests.

Modified:
    incubator/libcloud/trunk/libcloud/storage/base.py
    incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
    incubator/libcloud/trunk/test/storage/test_cloudfiles.py
    incubator/libcloud/trunk/test/storage/test_s3.py

Modified: incubator/libcloud/trunk/libcloud/storage/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/storage/base.py?rev=1103357&r1=1103356&r2=1103357&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/storage/base.py (original)
+++ incubator/libcloud/trunk/libcloud/storage/base.py Sun May 15 12:56:48 2011
@@ -178,16 +178,6 @@ class StorageDriver(object):
         self.connection.driver = self
         self.connection.connect()
 
-    def get_meta_data(self):
-        """
-        Return account meta data - total number of containers, objects and
-        number of bytes currently used.
-
-        @return A C{dict} with account meta data.
-        """
-        raise NotImplementedError(
-            'get_account_meta_data not implemented for this driver')
-
     def list_containters(self):
         raise NotImplementedError(
             'list_containers not implemented for this driver')

Modified: incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1103357&r1=1103356&r2=1103357&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Sun May 15 12:56:48 2011
@@ -147,23 +147,6 @@ class CloudFilesStorageDriver(StorageDri
     connectionCls = CloudFilesConnection
     hash_type = 'md5'
 
-    def get_meta_data(self):
-        response = self.connection.request('', method='HEAD')
-
-        if response.status == httplib.NO_CONTENT:
-            container_count = response.headers.get(
-                'x-account-container-count', 'unknown')
-            object_count = response.headers.get(
-                'x-account-object-count', 'unknown')
-            bytes_used = response.headers.get(
-                'x-account-bytes-used', 'unknown')
-
-            return { 'container_count': int(container_count),
-                      'object_count': int(object_count),
-                      'bytes_used': int(bytes_used) }
-
-        raise LibcloudError('Unexpected status code: %s' % (response.status))
-
     def list_containers(self):
         response = self.connection.request('')
 
@@ -351,6 +334,23 @@ class CloudFilesStorageDriver(StorageDri
 
         raise LibcloudError('Unexpected status code: %s' % (response.status))
 
+    def ex_get_meta_data(self):
+        response = self.connection.request('', method='HEAD')
+
+        if response.status == httplib.NO_CONTENT:
+            container_count = response.headers.get(
+                'x-account-container-count', 'unknown')
+            object_count = response.headers.get(
+                'x-account-object-count', 'unknown')
+            bytes_used = response.headers.get(
+                'x-account-bytes-used', 'unknown')
+
+            return { 'container_count': int(container_count),
+                      'object_count': int(object_count),
+                      'bytes_used': int(bytes_used) }
+
+        raise LibcloudError('Unexpected status code: %s' % (response.status))
+
     def _put_object(self, container, object_name, upload_func,
                     upload_func_kwargs, extra=None, file_path=None,
                     iterator=None, verify_hash=True):

Modified: incubator/libcloud/trunk/test/storage/test_cloudfiles.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/storage/test_cloudfiles.py?rev=1103357&r1=1103356&r2=1103357&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/storage/test_cloudfiles.py (original)
+++ incubator/libcloud/trunk/test/storage/test_cloudfiles.py Sun May 15 12:56:48 2011
@@ -52,9 +52,6 @@ class CloudFilesTests(unittest.TestCase)
     def tearDown(self):
         self._remove_test_file()
 
-    def test_get_meta_data(self):
-        self.driver.get_meta_data()
-
     def test_invalid_json_throws_exception(self):
         CloudFilesMockHttp.type = 'MALFORMED_JSON'
         try:
@@ -399,6 +396,12 @@ class CloudFilesTests(unittest.TestCase)
         else:
             self.fail('Object does not exist but an exception was not thrown')
 
+    def test_ex_get_meta_data(self):
+        meta_data = self.driver.ex_get_meta_data()
+        self.assertTrue(isinstance(meta_data, dict))
+        self.assertTrue('object_count' in meta_data)
+        self.assertTrue('container_count' in meta_data)
+        self.assertTrue('bytes_used' in meta_data)
 
     def _remove_test_file(self):
         file_path = os.path.abspath(__file__) + '.temp'

Modified: incubator/libcloud/trunk/test/storage/test_s3.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/storage/test_s3.py?rev=1103357&r1=1103356&r2=1103357&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/storage/test_s3.py (original)
+++ incubator/libcloud/trunk/test/storage/test_s3.py Sun May 15 12:56:48 2011
@@ -73,14 +73,6 @@ class S3Tests(unittest.TestCase):
         else:
             self.fail('Exception was not thrown')
 
-    def test_get_meta_data(self):
-        try:
-            self.driver.get_meta_data()
-        except NotImplementedError:
-            pass
-        else:
-            self.fail('Exception was not thrown')
-
     def test_list_containers_empty(self):
         S3MockHttp.type = 'list_containers_EMPTY'
         containers = self.driver.list_containers()



Mime
View raw message