]> git-server-git.apps.pok.os.sepia.ceph.com Git - radosgw-agent.git/commitdiff
add tests for listing objects in buckets with real http body from responses
authorAlfredo Deza <alfredo.deza@inktank.com>
Thu, 15 Jan 2015 19:28:02 +0000 (14:28 -0500)
committerAlfredo Deza <alfredo.deza@inktank.com>
Thu, 15 Jan 2015 19:28:26 +0000 (14:28 -0500)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
radosgw_agent/tests/test_client.py

index 521aa2c92c2a78bd5119eb54ebbcfc50483af666..bcd941f065ff81d5a88479e40ec2cae6d0585dc5 100644 (file)
@@ -463,7 +463,7 @@ class TestBotoCall(object):
             foo()
 
 
-class TestGETClientRequests(object):
+class TestGETClientRequestsPaths(object):
 
     def setup(self):
         self.connection = client.connection(
@@ -471,11 +471,12 @@ class TestGETClientRequests(object):
             True,
         )
 
-    def register(self):
+    def register(self, body=None):
+        body = body or '{}'
         httpretty.register_uri(
             httpretty.GET,
             re.compile("http://localhost:8888/(.*)"),
-            body='{}',
+            body=body,
             content_type="application/json",
         )
 
@@ -489,7 +490,6 @@ class TestGETClientRequests(object):
     @httpretty.activate
     def test_get_metadata_no_re_encoding(self):
         self.register()
-        #client.get_metadata(self.connection, 'bucket.instance', 'mybar%3Ar0z0.4140.1')
         client.get_metadata(self.connection, 'bucket.instance', 'mybar:r0z0.4140.1')
         server_request = httpretty.last_request()
         assert server_request.path == '/admin/metadata/bucket.instance?key=mybar%3Ar0z0.4140.1'
@@ -515,7 +515,6 @@ class TestGETClientRequests(object):
         server_request = httpretty.last_request()
         assert server_request.path == '/admin/metadata/bucket'
 
-
     @httpretty.activate
     def test_url_response(self):
 
@@ -527,3 +526,58 @@ class TestGETClientRequests(object):
         )
         result = client.request(self.connection, 'get', '/%7E~')
         assert result == {'msg': 'ok'}
+
+
+class TestClientListObjectsInBucket(object):
+
+    def setup(self):
+        self.connection = client.connection(
+            client.Endpoint('localhost', 8888, False, 'key', 'secret'),
+            True,
+        )
+        self.body = """
+        [
+            {
+                "name": "mahobject/",
+                "etag": "d41d8cd98f00b204e9800998ecf8427e",
+                "content_type": "application/octet-stream",
+                "last_modified": "2015-01-15T15:24:42.000Z",
+                "storage_class": "STANDARD",
+                "owner": {
+                    "display_name": "client1-system-user",
+                    "id": "client1-system-user"
+                }
+            }
+        ]
+        """
+
+    def register(self, body=None):
+        body = body or self.body
+        httpretty.register_uri(
+            httpretty.GET,
+            re.compile("http://localhost:8888/(.*)"),
+            body=body,
+            content_type="application/json",
+        )
+
+    @httpretty.activate
+    def test_get_bucket_is_a_single_item(self):
+        self.register()
+        result = client.get_bucket_list(self.connection)
+        assert len(result) == 1
+
+    @httpretty.activate
+    def test_get_bucket_has_right_metadata(self):
+        self.register()
+        result = client.get_bucket_list(self.connection)
+        obj = result[0]
+        owner = {
+            "display_name": "client1-system-user",
+            "id": "client1-system-user"
+        }
+        assert obj['name'] == 'mahobject/'
+        assert obj['etag'] == 'd41d8cd98f00b204e9800998ecf8427e'
+        assert obj['content_type'] == 'application/octet-stream'
+        assert obj['last_modified'] == '2015-01-15T15:24:42.000Z'
+        assert obj['storage_class'] == 'STANDARD'
+        assert obj['owner'] == owner