]> git-server-git.apps.pok.os.sepia.ceph.com Git - radosgw-agent.git/commitdiff
tests for the new get_worker_bounds behavior
authorAlfredo Deza <adeza@redhat.com>
Tue, 20 Jan 2015 18:53:39 +0000 (13:53 -0500)
committerAlfredo Deza <adeza@redhat.com>
Wed, 28 Jan 2015 18:43:07 +0000 (13:43 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
radosgw_agent/tests/test_client.py

index 40dc894d1a51ec11e1097f7f7199f98a9852c072..2c942845532f869af956a25d7f0ff4dd234b778b 100644 (file)
@@ -6,6 +6,7 @@ import re
 
 from radosgw_agent import client
 from radosgw_agent import exceptions as exc
+from radosgw_agent.constants import DEFAULT_TIME
 
 # parametrization helpers
 
@@ -582,3 +583,65 @@ class TestClientListObjectsInBucket(object):
         assert obj['last_modified'] == '2015-01-15T15:24:42.000Z'
         assert obj['storage_class'] == 'STANDARD'
         assert obj['owner'] == owner
+
+
+
+class TestClientGetWorkerBound(object):
+
+    def setup(self):
+        self.connection = client.connection(
+            client.Endpoint('localhost', 8888, False, 'key', 'secret'),
+            True,
+        )
+        self.body = """
+        {"marker": "00000000002.2.3",
+            "markers": [
+                {
+                    "entity": "radosgw-agent",
+                    "items_in_progress": [
+                        {
+                            "name": "hello",
+                            "timestamp": "0.000000"
+                        }
+                    ],
+                    "position_marker": "00000000002.2.3",
+                    "position_time": "0.000000"
+                }
+            ],
+         "oldest_time": "0.000000"
+        }
+        """
+
+    def register(self, body=None, status=200):
+        body = body or self.body
+        httpretty.register_uri(
+            httpretty.GET,
+            re.compile("http://localhost:8888/(.*)"),
+            body=body,
+            content_type="application/json",
+            status=status
+        )
+
+    @httpretty.activate
+    def test_get_bound_has_right_metadata(self):
+        self.register()
+        result = client.get_worker_bound(
+            self.connection,
+            'bucket-index',
+            'beast:us-east'
+        )
+        assert result['marker'] == "00000000002.2.3"
+        assert result['retries'] == set(['hello'])
+        assert result['oldest_time'] == "0.000000"
+
+    @httpretty.activate
+    def test_get_bound_fails_fallsback_to_defaults(self):
+        self.register(status=404)
+        result = client.get_worker_bound(
+            self.connection,
+            'bucket-index',
+            'beast:us-east'
+        )
+        assert result['marker'] == " "
+        assert result['retries'] == []
+        assert result['oldest_time'] == DEFAULT_TIME