pep8 fix: assertEquals -> assertEqual

assertEquals is deprecated in py3 in
dir: test/unit/container/*

Change-Id: I3333022ed63ce03198bc73147246d91d2442a440
This commit is contained in:
janonymous 2015-08-06 00:18:52 +05:30
parent 5b24b22498
commit ed3aec2146
5 changed files with 738 additions and 738 deletions

View File

@ -90,8 +90,8 @@ class TestAuditor(unittest.TestCase):
with mock.patch('swift.container.auditor.audit_location_generator', with mock.patch('swift.container.auditor.audit_location_generator',
fake_audit_location_generator): fake_audit_location_generator):
self.assertRaises(ValueError, test_auditor.run_forever) self.assertRaises(ValueError, test_auditor.run_forever)
self.assertEquals(test_auditor.container_failures, 2 * call_times) self.assertEqual(test_auditor.container_failures, 2 * call_times)
self.assertEquals(test_auditor.container_passes, 3 * call_times) self.assertEqual(test_auditor.container_passes, 3 * call_times)
@mock.patch('swift.container.auditor.ContainerBroker', FakeContainerBroker) @mock.patch('swift.container.auditor.ContainerBroker', FakeContainerBroker)
def test_run_once(self): def test_run_once(self):
@ -105,8 +105,8 @@ class TestAuditor(unittest.TestCase):
with mock.patch('swift.container.auditor.audit_location_generator', with mock.patch('swift.container.auditor.audit_location_generator',
fake_audit_location_generator): fake_audit_location_generator):
test_auditor.run_once() test_auditor.run_once()
self.assertEquals(test_auditor.container_failures, 2) self.assertEqual(test_auditor.container_failures, 2)
self.assertEquals(test_auditor.container_passes, 3) self.assertEqual(test_auditor.container_passes, 3)
@mock.patch('swift.container.auditor.ContainerBroker', FakeContainerBroker) @mock.patch('swift.container.auditor.ContainerBroker', FakeContainerBroker)
def test_container_auditor(self): def test_container_auditor(self):
@ -116,8 +116,8 @@ class TestAuditor(unittest.TestCase):
for f in files: for f in files:
path = os.path.join(self.testdir, f) path = os.path.join(self.testdir, f)
test_auditor.container_audit(path) test_auditor.container_audit(path)
self.assertEquals(test_auditor.container_failures, 2) self.assertEqual(test_auditor.container_failures, 2)
self.assertEquals(test_auditor.container_passes, 3) self.assertEqual(test_auditor.container_passes, 3)
class TestAuditorMigrations(unittest.TestCase): class TestAuditorMigrations(unittest.TestCase):

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -85,22 +85,22 @@ class TestContainerSync(unittest.TestCase):
got = flo.read(2) got = flo.read(2)
self.assertTrue(len(got) <= 2) self.assertTrue(len(got) <= 2)
self.assertEquals(got, expect[:len(got)]) self.assertEqual(got, expect[:len(got)])
expect = expect[len(got):] expect = expect[len(got):]
got = flo.read(5) got = flo.read(5)
self.assertTrue(len(got) <= 5) self.assertTrue(len(got) <= 5)
self.assertEquals(got, expect[:len(got)]) self.assertEqual(got, expect[:len(got)])
expect = expect[len(got):] expect = expect[len(got):]
self.assertEquals(flo.read(), expect) self.assertEqual(flo.read(), expect)
self.assertEquals(flo.read(), '') self.assertEqual(flo.read(), '')
self.assertEquals(flo.read(2), '') self.assertEqual(flo.read(2), '')
flo = sync.FileLikeIter(iter(['123', '4567', '89', '0'])) flo = sync.FileLikeIter(iter(['123', '4567', '89', '0']))
self.assertEquals(flo.read(), '1234567890') self.assertEqual(flo.read(), '1234567890')
self.assertEquals(flo.read(), '') self.assertEqual(flo.read(), '')
self.assertEquals(flo.read(2), '') self.assertEqual(flo.read(2), '')
def assertLogMessage(self, msg_level, expected, skip=0): def assertLogMessage(self, msg_level, expected, skip=0):
for line in self.logger.get_lines_for_level(msg_level)[skip:]: for line in self.logger.get_lines_for_level(msg_level)[skip:]:
@ -129,7 +129,7 @@ class TestContainerSync(unittest.TestCase):
self.assertTrue(mock_ic.called) self.assertTrue(mock_ic.called)
conf_path, name, retry = mock_ic.call_args[0] conf_path, name, retry = mock_ic.call_args[0]
self.assertTrue(isinstance(conf_path, ConfigString)) self.assertTrue(isinstance(conf_path, ConfigString))
self.assertEquals(conf_path.contents.getvalue(), self.assertEqual(conf_path.contents.getvalue(),
dedent(sync.ic_conf_body)) dedent(sync.ic_conf_body))
self.assertLogMessage('warning', 'internal_client_conf_path') self.assertLogMessage('warning', 'internal_client_conf_path')
self.assertLogMessage('warning', 'internal-client.conf-sample') self.assertLogMessage('warning', 'internal-client.conf-sample')
@ -143,7 +143,7 @@ class TestContainerSync(unittest.TestCase):
self.assertTrue(cs.container_ring is cring) self.assertTrue(cs.container_ring is cring)
self.assertTrue(mock_ic.called) self.assertTrue(mock_ic.called)
conf_path, name, retry = mock_ic.call_args[0] conf_path, name, retry = mock_ic.call_args[0]
self.assertEquals(conf_path, ic_conf_path) self.assertEqual(conf_path, ic_conf_path)
sample_conf_filename = os.path.join( sample_conf_filename = os.path.join(
os.path.dirname(test.__file__), os.path.dirname(test.__file__),
@ -207,12 +207,12 @@ class TestContainerSync(unittest.TestCase):
sync.audit_location_generator = orig_audit_location_generator sync.audit_location_generator = orig_audit_location_generator
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
self.assertEquals(time_calls, [9]) self.assertEqual(time_calls, [9])
self.assertEquals(len(sleep_calls), 2) self.assertEqual(len(sleep_calls), 2)
self.assertTrue(sleep_calls[0] <= cs.interval) self.assertTrue(sleep_calls[0] <= cs.interval)
self.assertTrue(sleep_calls[1] == cs.interval - 1) self.assertTrue(sleep_calls[1] == cs.interval - 1)
self.assertEquals(audit_location_generator_calls, [2]) self.assertEqual(audit_location_generator_calls, [2])
self.assertEquals(cs.reported, 3602) self.assertEqual(cs.reported, 3602)
def test_run_once(self): def test_run_once(self):
# This runs runs_once with fakes twice, the first causing an interim # This runs runs_once with fakes twice, the first causing an interim
@ -255,9 +255,9 @@ class TestContainerSync(unittest.TestCase):
cs = sync.ContainerSync({}, container_ring=FakeRing()) cs = sync.ContainerSync({}, container_ring=FakeRing())
sync.audit_location_generator = fake_audit_location_generator sync.audit_location_generator = fake_audit_location_generator
cs.run_once(1, 2, a=3, b=4, verbose=True) cs.run_once(1, 2, a=3, b=4, verbose=True)
self.assertEquals(time_calls, [6]) self.assertEqual(time_calls, [6])
self.assertEquals(audit_location_generator_calls, [1]) self.assertEqual(audit_location_generator_calls, [1])
self.assertEquals(cs.reported, 3602) self.assertEqual(cs.reported, 3602)
cs.run_once() cs.run_once()
except Exception as err: except Exception as err:
if str(err) != 'we are now done': if str(err) != 'we are now done':
@ -267,22 +267,22 @@ class TestContainerSync(unittest.TestCase):
sync.audit_location_generator = orig_audit_location_generator sync.audit_location_generator = orig_audit_location_generator
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
self.assertEquals(time_calls, [10]) self.assertEqual(time_calls, [10])
self.assertEquals(audit_location_generator_calls, [2]) self.assertEqual(audit_location_generator_calls, [2])
self.assertEquals(cs.reported, 3604) self.assertEqual(cs.reported, 3604)
def test_container_sync_not_db(self): def test_container_sync_not_db(self):
cring = FakeRing() cring = FakeRing()
with mock.patch('swift.container.sync.InternalClient'): with mock.patch('swift.container.sync.InternalClient'):
cs = sync.ContainerSync({}, container_ring=cring) cs = sync.ContainerSync({}, container_ring=cring)
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
def test_container_sync_missing_db(self): def test_container_sync_missing_db(self):
cring = FakeRing() cring = FakeRing()
with mock.patch('swift.container.sync.InternalClient'): with mock.patch('swift.container.sync.InternalClient'):
cs = sync.ContainerSync({}, container_ring=cring) cs = sync.ContainerSync({}, container_ring=cring)
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
def test_container_sync_not_my_db(self): def test_container_sync_not_my_db(self):
# Db could be there due to handoff replication so test that we ignore # Db could be there due to handoff replication so test that we ignore
@ -302,24 +302,24 @@ class TestContainerSync(unittest.TestCase):
cs._myips = ['127.0.0.1'] # No match cs._myips = ['127.0.0.1'] # No match
cs._myport = 1 # No match cs._myport = 1 # No match
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
cs._myips = ['10.0.0.0'] # Match cs._myips = ['10.0.0.0'] # Match
cs._myport = 1 # No match cs._myport = 1 # No match
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
cs._myips = ['127.0.0.1'] # No match cs._myips = ['127.0.0.1'] # No match
cs._myport = 1000 # Match cs._myport = 1000 # Match
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
cs._myips = ['10.0.0.0'] # Match cs._myips = ['10.0.0.0'] # Match
cs._myport = 1000 # Match cs._myport = 1000 # Match
# This complete match will cause the 1 container failure since the # This complete match will cause the 1 container failure since the
# broker's info doesn't contain sync point keys # broker's info doesn't contain sync point keys
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
finally: finally:
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
@ -337,7 +337,7 @@ class TestContainerSync(unittest.TestCase):
# This complete match will cause the 1 container failure since the # This complete match will cause the 1 container failure since the
# broker's info doesn't contain sync point keys # broker's info doesn't contain sync point keys
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
sync.ContainerBroker = lambda p: FakeContainerBroker( sync.ContainerBroker = lambda p: FakeContainerBroker(
p, info={'account': 'a', 'container': 'c', p, info={'account': 'a', 'container': 'c',
@ -345,7 +345,7 @@ class TestContainerSync(unittest.TestCase):
# This complete match will not cause any more container failures # This complete match will not cause any more container failures
# since the broker indicates deletion # since the broker indicates deletion
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
finally: finally:
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
@ -365,8 +365,8 @@ class TestContainerSync(unittest.TestCase):
# This complete match will be skipped since the broker's metadata # This complete match will be skipped since the broker's metadata
# has no x-container-sync-to or x-container-sync-key # has no x-container-sync-to or x-container-sync-key
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
self.assertEquals(cs.container_skips, 1) self.assertEqual(cs.container_skips, 1)
sync.ContainerBroker = lambda p: FakeContainerBroker( sync.ContainerBroker = lambda p: FakeContainerBroker(
p, info={'account': 'a', 'container': 'c', p, info={'account': 'a', 'container': 'c',
@ -379,8 +379,8 @@ class TestContainerSync(unittest.TestCase):
# This complete match will be skipped since the broker's metadata # This complete match will be skipped since the broker's metadata
# has no x-container-sync-key # has no x-container-sync-key
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
self.assertEquals(cs.container_skips, 2) self.assertEqual(cs.container_skips, 2)
sync.ContainerBroker = lambda p: FakeContainerBroker( sync.ContainerBroker = lambda p: FakeContainerBroker(
p, info={'account': 'a', 'container': 'c', p, info={'account': 'a', 'container': 'c',
@ -393,8 +393,8 @@ class TestContainerSync(unittest.TestCase):
# This complete match will be skipped since the broker's metadata # This complete match will be skipped since the broker's metadata
# has no x-container-sync-to # has no x-container-sync-to
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
self.assertEquals(cs.container_skips, 3) self.assertEqual(cs.container_skips, 3)
sync.ContainerBroker = lambda p: FakeContainerBroker( sync.ContainerBroker = lambda p: FakeContainerBroker(
p, info={'account': 'a', 'container': 'c', p, info={'account': 'a', 'container': 'c',
@ -409,8 +409,8 @@ class TestContainerSync(unittest.TestCase):
# This complete match will cause a container failure since the # This complete match will cause a container failure since the
# sync-to won't validate as allowed. # sync-to won't validate as allowed.
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 3) self.assertEqual(cs.container_skips, 3)
sync.ContainerBroker = lambda p: FakeContainerBroker( sync.ContainerBroker = lambda p: FakeContainerBroker(
p, info={'account': 'a', 'container': 'c', p, info={'account': 'a', 'container': 'c',
@ -425,8 +425,8 @@ class TestContainerSync(unittest.TestCase):
# This complete match will succeed completely since the broker # This complete match will succeed completely since the broker
# get_items_since will return no new rows. # get_items_since will return no new rows.
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 3) self.assertEqual(cs.container_skips, 3)
finally: finally:
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
@ -450,8 +450,8 @@ class TestContainerSync(unittest.TestCase):
cs.allowed_sync_hosts = ['127.0.0.1'] cs.allowed_sync_hosts = ['127.0.0.1']
# This sync will fail since the items_since data is bad. # This sync will fail since the items_since data is bad.
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
# Set up fake times to make the sync short-circuit as having taken # Set up fake times to make the sync short-circuit as having taken
# too long # too long
@ -468,8 +468,8 @@ class TestContainerSync(unittest.TestCase):
# as to be time to move on (before it ever actually tries to do # as to be time to move on (before it ever actually tries to do
# anything). # anything).
cs.container_sync('isa.db') cs.container_sync('isa.db')
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
finally: finally:
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
sync.time = orig_time sync.time = orig_time
@ -501,10 +501,10 @@ class TestContainerSync(unittest.TestCase):
cs.allowed_sync_hosts = ['127.0.0.1'] cs.allowed_sync_hosts = ['127.0.0.1']
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Succeeds because no rows match # Succeeds because no rows match
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, None) self.assertEqual(fcb.sync_point1, None)
self.assertEquals(fcb.sync_point2, -1) self.assertEqual(fcb.sync_point2, -1)
def fake_hash_path(account, container, obj, raw_digest=False): def fake_hash_path(account, container, obj, raw_digest=False):
# Ensures that all rows match for full syncing, ordinal is 0 # Ensures that all rows match for full syncing, ordinal is 0
@ -529,10 +529,10 @@ class TestContainerSync(unittest.TestCase):
cs.allowed_sync_hosts = ['127.0.0.1'] cs.allowed_sync_hosts = ['127.0.0.1']
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Succeeds because the two sync points haven't deviated yet # Succeeds because the two sync points haven't deviated yet
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, -1) self.assertEqual(fcb.sync_point1, -1)
self.assertEquals(fcb.sync_point2, -1) self.assertEqual(fcb.sync_point2, -1)
fcb = FakeContainerBroker( fcb = FakeContainerBroker(
'path', 'path',
@ -550,10 +550,10 @@ class TestContainerSync(unittest.TestCase):
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Fails because container_sync_row will fail since the row has no # Fails because container_sync_row will fail since the row has no
# 'deleted' key # 'deleted' key
self.assertEquals(cs.container_failures, 2) self.assertEqual(cs.container_failures, 2)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, None) self.assertEqual(fcb.sync_point1, None)
self.assertEquals(fcb.sync_point2, -1) self.assertEqual(fcb.sync_point2, -1)
def fake_delete_object(*args, **kwargs): def fake_delete_object(*args, **kwargs):
raise ClientException raise ClientException
@ -577,10 +577,10 @@ class TestContainerSync(unittest.TestCase):
cs.allowed_sync_hosts = ['127.0.0.1'] cs.allowed_sync_hosts = ['127.0.0.1']
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Fails because delete_object fails # Fails because delete_object fails
self.assertEquals(cs.container_failures, 3) self.assertEqual(cs.container_failures, 3)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, None) self.assertEqual(fcb.sync_point1, None)
self.assertEquals(fcb.sync_point2, -1) self.assertEqual(fcb.sync_point2, -1)
fcb = FakeContainerBroker( fcb = FakeContainerBroker(
'path', 'path',
@ -602,10 +602,10 @@ class TestContainerSync(unittest.TestCase):
cs.allowed_sync_hosts = ['127.0.0.1'] cs.allowed_sync_hosts = ['127.0.0.1']
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Succeeds because delete_object succeeds # Succeeds because delete_object succeeds
self.assertEquals(cs.container_failures, 3) self.assertEqual(cs.container_failures, 3)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, None) self.assertEqual(fcb.sync_point1, None)
self.assertEquals(fcb.sync_point2, 1) self.assertEqual(fcb.sync_point2, 1)
def test_container_second_loop(self): def test_container_second_loop(self):
cring = FakeRing() cring = FakeRing()
@ -640,10 +640,10 @@ class TestContainerSync(unittest.TestCase):
cs.allowed_sync_hosts = ['127.0.0.1'] cs.allowed_sync_hosts = ['127.0.0.1']
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Succeeds because no rows match # Succeeds because no rows match
self.assertEquals(cs.container_failures, 0) self.assertEqual(cs.container_failures, 0)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, 1) self.assertEqual(fcb.sync_point1, 1)
self.assertEquals(fcb.sync_point2, None) self.assertEqual(fcb.sync_point2, None)
def fake_hash_path(account, container, obj, raw_digest=False): def fake_hash_path(account, container, obj, raw_digest=False):
# Ensures that all rows match for second loop, ordinal is 0 and # Ensures that all rows match for second loop, ordinal is 0 and
@ -671,10 +671,10 @@ class TestContainerSync(unittest.TestCase):
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Fails because row is missing 'deleted' key # Fails because row is missing 'deleted' key
# Nevertheless the fault is skipped # Nevertheless the fault is skipped
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, 1) self.assertEqual(fcb.sync_point1, 1)
self.assertEquals(fcb.sync_point2, None) self.assertEqual(fcb.sync_point2, None)
fcb = FakeContainerBroker( fcb = FakeContainerBroker(
'path', 'path',
@ -693,10 +693,10 @@ class TestContainerSync(unittest.TestCase):
cs.container_sync('isa.db') cs.container_sync('isa.db')
# Succeeds because row now has 'deleted' key and delete_object # Succeeds because row now has 'deleted' key and delete_object
# succeeds # succeeds
self.assertEquals(cs.container_failures, 1) self.assertEqual(cs.container_failures, 1)
self.assertEquals(cs.container_skips, 0) self.assertEqual(cs.container_skips, 0)
self.assertEquals(fcb.sync_point1, 1) self.assertEqual(fcb.sync_point1, 1)
self.assertEquals(fcb.sync_point2, None) self.assertEqual(fcb.sync_point2, None)
finally: finally:
sync.ContainerBroker = orig_ContainerBroker sync.ContainerBroker = orig_ContainerBroker
sync.hash_path = orig_hash_path sync.hash_path = orig_hash_path
@ -720,18 +720,18 @@ class TestContainerSync(unittest.TestCase):
def fake_delete_object(path, name=None, headers=None, proxy=None, def fake_delete_object(path, name=None, headers=None, proxy=None,
logger=None, timeout=None): logger=None, timeout=None):
self.assertEquals(path, 'http://sync/to/path') self.assertEqual(path, 'http://sync/to/path')
self.assertEquals(name, 'object') self.assertEqual(name, 'object')
if realm: if realm:
self.assertEquals(headers, { self.assertEqual(headers, {
'x-container-sync-auth': 'x-container-sync-auth':
'US abcdef 90e95aabb45a6cdc0892a3db5535e7f918428c90', 'US abcdef 90e95aabb45a6cdc0892a3db5535e7f918428c90',
'x-timestamp': '1.2'}) 'x-timestamp': '1.2'})
else: else:
self.assertEquals( self.assertEqual(
headers, headers,
{'x-container-sync-key': 'key', 'x-timestamp': '1.2'}) {'x-container-sync-key': 'key', 'x-timestamp': '1.2'})
self.assertEquals(proxy, 'http://proxy') self.assertEqual(proxy, 'http://proxy')
self.assertEqual(timeout, 5.0) self.assertEqual(timeout, 5.0)
self.assertEqual(logger, self.logger) self.assertEqual(logger, self.logger)
@ -749,7 +749,7 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_deletes, 1) self.assertEqual(cs.container_deletes, 1)
exc = [] exc = []
@ -766,9 +766,9 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_deletes, 1) self.assertEqual(cs.container_deletes, 1)
self.assertEquals(len(exc), 1) self.assertEqual(len(exc), 1)
self.assertEquals(str(exc[-1]), 'test exception') self.assertEqual(str(exc[-1]), 'test exception')
def fake_delete_object(*args, **kwargs): def fake_delete_object(*args, **kwargs):
exc.append(ClientException('test client exception')) exc.append(ClientException('test client exception'))
@ -783,9 +783,9 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_deletes, 1) self.assertEqual(cs.container_deletes, 1)
self.assertEquals(len(exc), 2) self.assertEqual(len(exc), 2)
self.assertEquals(str(exc[-1]), 'test client exception') self.assertEqual(str(exc[-1]), 'test client exception')
def fake_delete_object(*args, **kwargs): def fake_delete_object(*args, **kwargs):
exc.append(ClientException('test client exception', exc.append(ClientException('test client exception',
@ -801,9 +801,9 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_deletes, 2) self.assertEqual(cs.container_deletes, 2)
self.assertEquals(len(exc), 3) self.assertEqual(len(exc), 3)
self.assertEquals(str(exc[-1]), 'test client exception: 404') self.assertEqual(str(exc[-1]), 'test client exception: 404')
finally: finally:
sync.uuid = orig_uuid sync.uuid = orig_uuid
sync.delete_object = orig_delete_object sync.delete_object = orig_delete_object
@ -829,8 +829,8 @@ class TestContainerSync(unittest.TestCase):
def fake_put_object(sync_to, name=None, headers=None, def fake_put_object(sync_to, name=None, headers=None,
contents=None, proxy=None, logger=None, contents=None, proxy=None, logger=None,
timeout=None): timeout=None):
self.assertEquals(sync_to, 'http://sync/to/path') self.assertEqual(sync_to, 'http://sync/to/path')
self.assertEquals(name, 'object') self.assertEqual(name, 'object')
if realm: if realm:
self.assertEqual(headers, { self.assertEqual(headers, {
'x-container-sync-auth': 'x-container-sync-auth':
@ -840,14 +840,14 @@ class TestContainerSync(unittest.TestCase):
'other-header': 'other header value', 'other-header': 'other header value',
'content-type': 'text/plain'}) 'content-type': 'text/plain'})
else: else:
self.assertEquals(headers, { self.assertEqual(headers, {
'x-container-sync-key': 'key', 'x-container-sync-key': 'key',
'x-timestamp': '1.2', 'x-timestamp': '1.2',
'other-header': 'other header value', 'other-header': 'other header value',
'etag': 'etagvalue', 'etag': 'etagvalue',
'content-type': 'text/plain'}) 'content-type': 'text/plain'})
self.assertEquals(contents.read(), 'contents') self.assertEqual(contents.read(), 'contents')
self.assertEquals(proxy, 'http://proxy') self.assertEqual(proxy, 'http://proxy')
self.assertEqual(timeout, 5.0) self.assertEqual(timeout, 5.0)
self.assertEqual(logger, self.logger) self.assertEqual(logger, self.logger)
@ -876,11 +876,11 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 1) self.assertEqual(cs.container_puts, 1)
def fake_get_object(acct, con, obj, headers, acceptable_statuses): def fake_get_object(acct, con, obj, headers, acceptable_statuses):
self.assertEquals(headers['X-Newest'], True) self.assertEqual(headers['X-Newest'], True)
self.assertEquals(headers['X-Backend-Storage-Policy-Index'], self.assertEqual(headers['X-Backend-Storage-Policy-Index'],
'0') '0')
return (200, return (200,
{'date': 'date value', {'date': 'date value',
@ -902,13 +902,13 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 2) self.assertEqual(cs.container_puts, 2)
exc = [] exc = []
def fake_get_object(acct, con, obj, headers, acceptable_statuses): def fake_get_object(acct, con, obj, headers, acceptable_statuses):
self.assertEquals(headers['X-Newest'], True) self.assertEqual(headers['X-Newest'], True)
self.assertEquals(headers['X-Backend-Storage-Policy-Index'], self.assertEqual(headers['X-Backend-Storage-Policy-Index'],
'0') '0')
exc.append(Exception('test exception')) exc.append(Exception('test exception'))
raise exc[-1] raise exc[-1]
@ -922,15 +922,15 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 2) self.assertEqual(cs.container_puts, 2)
self.assertEquals(len(exc), 1) self.assertEqual(len(exc), 1)
self.assertEquals(str(exc[-1]), 'test exception') self.assertEqual(str(exc[-1]), 'test exception')
exc = [] exc = []
def fake_get_object(acct, con, obj, headers, acceptable_statuses): def fake_get_object(acct, con, obj, headers, acceptable_statuses):
self.assertEquals(headers['X-Newest'], True) self.assertEqual(headers['X-Newest'], True)
self.assertEquals(headers['X-Backend-Storage-Policy-Index'], self.assertEqual(headers['X-Backend-Storage-Policy-Index'],
'0') '0')
exc.append(ClientException('test client exception')) exc.append(ClientException('test client exception'))
@ -945,13 +945,13 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 2) self.assertEqual(cs.container_puts, 2)
self.assertEquals(len(exc), 1) self.assertEqual(len(exc), 1)
self.assertEquals(str(exc[-1]), 'test client exception') self.assertEqual(str(exc[-1]), 'test client exception')
def fake_get_object(acct, con, obj, headers, acceptable_statuses): def fake_get_object(acct, con, obj, headers, acceptable_statuses):
self.assertEquals(headers['X-Newest'], True) self.assertEqual(headers['X-Newest'], True)
self.assertEquals(headers['X-Backend-Storage-Policy-Index'], self.assertEqual(headers['X-Backend-Storage-Policy-Index'],
'0') '0')
return (200, {'other-header': 'other header value', return (200, {'other-header': 'other header value',
'x-timestamp': '1.2', 'etag': '"etagvalue"'}, 'x-timestamp': '1.2', 'etag': '"etagvalue"'},
@ -970,7 +970,7 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 2) self.assertEqual(cs.container_puts, 2)
self.assertLogMessage('info', 'Unauth') self.assertLogMessage('info', 'Unauth')
def fake_put_object(*args, **kwargs): def fake_put_object(*args, **kwargs):
@ -985,7 +985,7 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 2) self.assertEqual(cs.container_puts, 2)
self.assertLogMessage('info', 'Not found', 1) self.assertLogMessage('info', 'Not found', 1)
def fake_put_object(*args, **kwargs): def fake_put_object(*args, **kwargs):
@ -1000,7 +1000,7 @@ class TestContainerSync(unittest.TestCase):
'key', FakeContainerBroker('broker'), 'key', FakeContainerBroker('broker'),
{'account': 'a', 'container': 'c', 'storage_policy_index': 0}, {'account': 'a', 'container': 'c', 'storage_policy_index': 0},
realm, realm_key)) realm, realm_key))
self.assertEquals(cs.container_puts, 2) self.assertEqual(cs.container_puts, 2)
self.assertLogMessage('error', 'ERROR Syncing') self.assertLogMessage('error', 'ERROR Syncing')
finally: finally:
sync.uuid = orig_uuid sync.uuid = orig_uuid

View File

@ -68,10 +68,10 @@ class TestContainerUpdater(unittest.TestCase):
}) })
self.assertTrue(hasattr(cu, 'logger')) self.assertTrue(hasattr(cu, 'logger'))
self.assertTrue(cu.logger is not None) self.assertTrue(cu.logger is not None)
self.assertEquals(cu.devices, self.devices_dir) self.assertEqual(cu.devices, self.devices_dir)
self.assertEquals(cu.interval, 1) self.assertEqual(cu.interval, 1)
self.assertEquals(cu.concurrency, 2) self.assertEqual(cu.concurrency, 2)
self.assertEquals(cu.node_timeout, 5) self.assertEqual(cu.node_timeout, 5)
self.assertTrue(cu.get_account_ring() is not None) self.assertTrue(cu.get_account_ring() is not None)
def test_run_once(self): def test_run_once(self):
@ -96,19 +96,19 @@ class TestContainerUpdater(unittest.TestCase):
cb.initialize(normalize_timestamp(1), 0) cb.initialize(normalize_timestamp(1), 0)
cu.run_once() cu.run_once()
info = cb.get_info() info = cb.get_info()
self.assertEquals(info['object_count'], 0) self.assertEqual(info['object_count'], 0)
self.assertEquals(info['bytes_used'], 0) self.assertEqual(info['bytes_used'], 0)
self.assertEquals(info['reported_object_count'], 0) self.assertEqual(info['reported_object_count'], 0)
self.assertEquals(info['reported_bytes_used'], 0) self.assertEqual(info['reported_bytes_used'], 0)
cb.put_object('o', normalize_timestamp(2), 3, 'text/plain', cb.put_object('o', normalize_timestamp(2), 3, 'text/plain',
'68b329da9893e34099c7d8ad5cb9c940') '68b329da9893e34099c7d8ad5cb9c940')
cu.run_once() cu.run_once()
info = cb.get_info() info = cb.get_info()
self.assertEquals(info['object_count'], 1) self.assertEqual(info['object_count'], 1)
self.assertEquals(info['bytes_used'], 3) self.assertEqual(info['bytes_used'], 3)
self.assertEquals(info['reported_object_count'], 0) self.assertEqual(info['reported_object_count'], 0)
self.assertEquals(info['reported_bytes_used'], 0) self.assertEqual(info['reported_bytes_used'], 0)
def accept(sock, addr, return_code): def accept(sock, addr, return_code):
try: try:
@ -118,7 +118,7 @@ class TestContainerUpdater(unittest.TestCase):
out.write('HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n' % out.write('HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n' %
return_code) return_code)
out.flush() out.flush()
self.assertEquals(inc.readline(), self.assertEqual(inc.readline(),
'PUT /sda1/0/a/c HTTP/1.1\r\n') 'PUT /sda1/0/a/c HTTP/1.1\r\n')
headers = {} headers = {}
line = inc.readline() line = inc.readline()
@ -154,10 +154,10 @@ class TestContainerUpdater(unittest.TestCase):
if err: if err:
raise err raise err
info = cb.get_info() info = cb.get_info()
self.assertEquals(info['object_count'], 1) self.assertEqual(info['object_count'], 1)
self.assertEquals(info['bytes_used'], 3) self.assertEqual(info['bytes_used'], 3)
self.assertEquals(info['reported_object_count'], 1) self.assertEqual(info['reported_object_count'], 1)
self.assertEquals(info['reported_bytes_used'], 3) self.assertEqual(info['reported_bytes_used'], 3)
@mock.patch('os.listdir') @mock.patch('os.listdir')
def test_listdir_with_exception(self, mock_listdir): def test_listdir_with_exception(self, mock_listdir):
@ -250,10 +250,10 @@ class TestContainerUpdater(unittest.TestCase):
if err: if err:
raise err raise err
info = cb.get_info() info = cb.get_info()
self.assertEquals(info['object_count'], 1) self.assertEqual(info['object_count'], 1)
self.assertEquals(info['bytes_used'], 3) self.assertEqual(info['bytes_used'], 3)
self.assertEquals(info['reported_object_count'], 1) self.assertEqual(info['reported_object_count'], 1)
self.assertEquals(info['reported_bytes_used'], 3) self.assertEqual(info['reported_bytes_used'], 3)
if __name__ == '__main__': if __name__ == '__main__':