]> git-server-git.apps.pok.os.sepia.ceph.com Git - radosgw-agent.git/commitdiff
fix the worker exception tests 18/head
authorAlfredo Deza <adeza@redhat.com>
Mon, 19 Jan 2015 16:58:34 +0000 (11:58 -0500)
committerAlfredo Deza <adeza@redhat.com>
Mon, 19 Jan 2015 16:58:34 +0000 (11:58 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
radosgw_agent/tests/test_worker.py

index 093a411b2c3e33e1ed77ea195f6ba0801f16e3a8..99edb9d03c939541fca5769e7f08f6fc85ddda5c 100644 (file)
@@ -3,6 +3,7 @@ import py.test
 import time
 
 from radosgw_agent import worker, client
+from radosgw_agent.exceptions import HttpError, NotFound, BucketEmpty
 
 
 class TestSyncObject(object):
@@ -10,8 +11,8 @@ class TestSyncObject(object):
     def setup(self):
         # setup the fake client, but get the exceptions back into place
         self.client = Mock()
-        self.client.HttpError = client.HttpError
-        self.client.NotFound = client.NotFound
+        self.client.HttpError = HttpError
+        self.client.NotFound = NotFound
 
         self.src = Mock()
         self.src.zone.name = 'Zone Name'
@@ -23,7 +24,7 @@ class TestSyncObject(object):
             assert w.sync_object('mah-bucket', 'mah-object') is True
 
     def test_syncs_not_found_on_master_deleting_from_secondary(self):
-        self.client.sync_object_intra_region = Mock(side_effect=client.NotFound(404, ''))
+        self.client.sync_object_intra_region = Mock(side_effect=NotFound(404, ''))
 
         with patch('radosgw_agent.worker.client', self.client):
             w = worker.DataWorker(None, None, None, self.src, None, daemon_id=1)
@@ -31,8 +32,8 @@ class TestSyncObject(object):
             assert w.sync_object('mah-bucket', 'mah-object') is True
 
     def test_syncs_deletes_from_secondary(self):
-        self.client.sync_object_intra_region = Mock(side_effect=client.NotFound(404, ''))
-        self.client.delete_object = Mock(side_effect=client.NotFound(404, ''))
+        self.client.sync_object_intra_region = Mock(side_effect=NotFound(404, ''))
+        self.client.delete_object = Mock(side_effect=NotFound(404, ''))
 
         with patch('radosgw_agent.worker.client', self.client):
             w = worker.DataWorker(None, None, None, self.src, None, daemon_id=1)
@@ -40,7 +41,7 @@ class TestSyncObject(object):
             assert w.sync_object('mah-bucket', 'mah-object') is False
 
     def test_syncs_could_not_delete_from_secondary(self):
-        self.client.sync_object_intra_region = Mock(side_effect=client.NotFound(404, ''))
+        self.client.sync_object_intra_region = Mock(side_effect=NotFound(404, ''))
         self.client.delete_object = Mock(side_effect=ValueError('unexpected error'))
 
         with patch('radosgw_agent.worker.client', self.client):
@@ -51,7 +52,7 @@ class TestSyncObject(object):
                 w.sync_object('mah-bucket', 'mah-object')
 
     def test_syncs_encounters_a_http_error(self):
-        self.client.sync_object_intra_region = Mock(side_effect=client.HttpError(400, ''))
+        self.client.sync_object_intra_region = Mock(side_effect=HttpError(400, ''))
 
         with patch('radosgw_agent.worker.client', self.client):
             w = worker.DataWorker(None, None, None, self.src, None, daemon_id=1)
@@ -98,7 +99,7 @@ class TestSyncObject(object):
             assert w.sync_object('mah-bucket', 'mah-object') is True
 
     def test_wait_for_object_state_not_found_raises_sync_failed(self):
-        self.client.get_op_state = Mock(side_effect=client.NotFound(404, ''))
+        self.client.get_op_state = Mock(side_effect=NotFound(404, ''))
         with patch('radosgw_agent.worker.client', self.client):
             w = worker.DataWorker(None, None, None, self.src, None, daemon_id=1)
             with py.test.raises(worker.SyncFailed) as exc:
@@ -134,10 +135,10 @@ class TestSyncObject(object):
     def test_sync_bucket_delayed_not_found(self):
         class fake_iterable(object):
             def __iter__(self):
-                raise client.BucketEmpty
+                raise BucketEmpty
         with patch('radosgw_agent.worker.client', self.client):
             w = worker.DataWorker(None, None, None, self.src, None, daemon_id=1)
             w.sync_object = lambda *a: None
             objects = fake_iterable()
-            with py.test.raises(client.BucketEmpty):
+            with py.test.raises(BucketEmpty):
                 w.sync_bucket('foo', objects)