import time
from radosgw_agent import worker, client
+from radosgw_agent.exceptions import HttpError, NotFound, BucketEmpty
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'
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)
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)
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):
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)
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:
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)