Merge "Use more specific asserts in test/unit/account tests"
This commit is contained in:
commit
16bc798f0e
@ -252,9 +252,9 @@ class TestAuditorRealBroker(unittest.TestCase):
|
|||||||
error_lines = test_auditor.logger.get_lines_for_level('error')
|
error_lines = test_auditor.logger.get_lines_for_level('error')
|
||||||
self.assertEqual(len(error_lines), 1)
|
self.assertEqual(len(error_lines), 1)
|
||||||
error_message = error_lines[0]
|
error_message = error_lines[0]
|
||||||
self.assertTrue(broker.db_file in error_message)
|
self.assertIn(broker.db_file, error_message)
|
||||||
self.assertTrue('container_count' in error_message)
|
self.assertIn('container_count', error_message)
|
||||||
self.assertTrue('does not match' in error_message)
|
self.assertIn('does not match', error_message)
|
||||||
self.assertEqual(test_auditor.logger.get_increment_counts(),
|
self.assertEqual(test_auditor.logger.get_increment_counts(),
|
||||||
{'failures': 1})
|
{'failures': 1})
|
||||||
|
|
||||||
|
@ -1062,7 +1062,7 @@ class TestAccountBrokerBeforeMetadata(TestAccountBroker):
|
|||||||
conn.execute('SELECT metadata FROM account_stat')
|
conn.execute('SELECT metadata FROM account_stat')
|
||||||
except BaseException as err:
|
except BaseException as err:
|
||||||
exc = err
|
exc = err
|
||||||
self.assertTrue('no such column: metadata' in str(exc))
|
self.assertIn('no such column: metadata', str(exc))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
AccountBroker.create_account_stat_table = \
|
AccountBroker.create_account_stat_table = \
|
||||||
@ -1149,12 +1149,12 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
|
|||||||
conn.execute('SELECT storage_policy_index FROM container')
|
conn.execute('SELECT storage_policy_index FROM container')
|
||||||
except BaseException as err:
|
except BaseException as err:
|
||||||
exc = err
|
exc = err
|
||||||
self.assertTrue('no such column: storage_policy_index' in str(exc))
|
self.assertIn('no such column: storage_policy_index', str(exc))
|
||||||
with broker.get() as conn:
|
with broker.get() as conn:
|
||||||
try:
|
try:
|
||||||
conn.execute('SELECT * FROM policy_stat')
|
conn.execute('SELECT * FROM policy_stat')
|
||||||
except sqlite3.OperationalError as err:
|
except sqlite3.OperationalError as err:
|
||||||
self.assertTrue('no such table: policy_stat' in str(err))
|
self.assertIn('no such table: policy_stat', str(err))
|
||||||
else:
|
else:
|
||||||
self.fail('database created with policy_stat table')
|
self.fail('database created with policy_stat table')
|
||||||
|
|
||||||
@ -1181,7 +1181,7 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
|
|||||||
''').fetchone()[0]
|
''').fetchone()[0]
|
||||||
except sqlite3.OperationalError as err:
|
except sqlite3.OperationalError as err:
|
||||||
# confirm that the table really isn't there
|
# confirm that the table really isn't there
|
||||||
self.assertTrue('no such table: policy_stat' in str(err))
|
self.assertIn('no such table: policy_stat', str(err))
|
||||||
else:
|
else:
|
||||||
self.fail('broker did not raise sqlite3.OperationalError '
|
self.fail('broker did not raise sqlite3.OperationalError '
|
||||||
'trying to select from policy_stat table!')
|
'trying to select from policy_stat table!')
|
||||||
@ -1330,7 +1330,7 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
|
|||||||
self.fail('mock exception was not raised')
|
self.fail('mock exception was not raised')
|
||||||
|
|
||||||
self.assertEqual(len(called), 1)
|
self.assertEqual(len(called), 1)
|
||||||
self.assertTrue('CREATE TABLE policy_stat' in called[0])
|
self.assertIn('CREATE TABLE policy_stat', called[0])
|
||||||
|
|
||||||
# nothing was committed
|
# nothing was committed
|
||||||
broker = AccountBroker(db_path, account='a')
|
broker = AccountBroker(db_path, account='a')
|
||||||
@ -1338,7 +1338,7 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
|
|||||||
try:
|
try:
|
||||||
conn.execute('SELECT * FROM policy_stat')
|
conn.execute('SELECT * FROM policy_stat')
|
||||||
except sqlite3.OperationalError as err:
|
except sqlite3.OperationalError as err:
|
||||||
self.assertTrue('no such table: policy_stat' in str(err))
|
self.assertIn('no such table: policy_stat', str(err))
|
||||||
else:
|
else:
|
||||||
self.fail('half upgraded database!')
|
self.fail('half upgraded database!')
|
||||||
container_count = conn.execute(
|
container_count = conn.execute(
|
||||||
@ -1503,7 +1503,7 @@ class AccountBrokerPreTrackContainerCountSetup(object):
|
|||||||
''').fetchone()[0]
|
''').fetchone()[0]
|
||||||
except sqlite3.OperationalError as err:
|
except sqlite3.OperationalError as err:
|
||||||
# confirm that the column really isn't there
|
# confirm that the column really isn't there
|
||||||
self.assertTrue('no such column: container_count' in str(err))
|
self.assertIn('no such column: container_count', str(err))
|
||||||
else:
|
else:
|
||||||
self.fail('broker did not raise sqlite3.OperationalError '
|
self.fail('broker did not raise sqlite3.OperationalError '
|
||||||
'trying to select container_count from policy_stat!')
|
'trying to select container_count from policy_stat!')
|
||||||
|
@ -2046,7 +2046,7 @@ class TestAccountController(unittest.TestCase):
|
|||||||
self.assertEqual(resp.status_int // 100, 2)
|
self.assertEqual(resp.status_int // 100, 2)
|
||||||
for key in resp.headers:
|
for key in resp.headers:
|
||||||
if 'storage-policy' in key.lower():
|
if 'storage-policy' in key.lower():
|
||||||
self.assertTrue(policy.name.lower() in key.lower())
|
self.assertIn(policy.name.lower(), key.lower())
|
||||||
|
|
||||||
def test_multiple_policies_in_use(self):
|
def test_multiple_policies_in_use(self):
|
||||||
ts = itertools.count()
|
ts = itertools.count()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user