Use assertIn instead of assertTrue(A in B)
Developers should use assertIn(A, B) instead of assertTrue(A in B ). TrivialFix Change-Id: I31e20fae988b71145ec7b82fa696a87c4dbcc4e3
This commit is contained in:
@@ -222,7 +222,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite):
|
||||
response = request.get_response(self.app)
|
||||
self.assertEqual(413, response.status_int)
|
||||
|
||||
self.assertTrue('Retry-After' in response.headers)
|
||||
self.assertIn('Retry-After', response.headers)
|
||||
retry_after = int(response.headers['Retry-After'])
|
||||
self.assertAlmostEqual(retry_after, 60, 1)
|
||||
|
||||
@@ -231,7 +231,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite):
|
||||
value = body["overLimit"]["details"].strip()
|
||||
self.assertEqual(expected, value)
|
||||
|
||||
self.assertTrue("retryAfter" in body["overLimit"])
|
||||
self.assertIn("retryAfter", body["overLimit"])
|
||||
retryAfter = body["overLimit"]["retryAfter"]
|
||||
self.assertEqual("60", retryAfter)
|
||||
|
||||
|
||||
@@ -69,13 +69,13 @@ class TestClusterController(TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', self.cluster)
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('cluster' in schema['properties'])
|
||||
self.assertIn('cluster', schema['properties'])
|
||||
self.assertTrue('cluster')
|
||||
|
||||
def test_get_schema_action_add_shard(self):
|
||||
schema = self.controller.get_schema('add_shard', self.add_shard)
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('add_shard' in schema['properties'])
|
||||
self.assertIn('add_shard', schema['properties'])
|
||||
|
||||
def test_validate_create(self):
|
||||
body = self.cluster
|
||||
|
||||
@@ -59,7 +59,7 @@ class TestClusterController(trove_testtools.TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', self.cluster)
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('cluster' in schema['properties'])
|
||||
self.assertIn('cluster', schema['properties'])
|
||||
self.assertTrue('cluster')
|
||||
|
||||
def test_validate_create(self):
|
||||
|
||||
@@ -73,7 +73,7 @@ class TestClusterController(trove_testtools.TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', self.cluster)
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('cluster' in schema['properties'])
|
||||
self.assertIn('cluster', schema['properties'])
|
||||
self.assertTrue('cluster')
|
||||
|
||||
def test_validate_create(self):
|
||||
|
||||
@@ -59,7 +59,7 @@ class TestClusterController(trove_testtools.TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', self.cluster)
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('cluster' in schema['properties'])
|
||||
self.assertIn('cluster', schema['properties'])
|
||||
self.assertTrue('cluster')
|
||||
|
||||
def test_validate_create(self):
|
||||
|
||||
@@ -58,7 +58,7 @@ class TestTroveContext(trove_testtools.TestCase):
|
||||
ctx_dict = ctx.to_dict()
|
||||
self.assertThat(ctx_dict.get('user'), Equals('test_user_id'))
|
||||
self.assertThat(ctx_dict.get('request_id'), Equals('test_req_id'))
|
||||
self.assertTrue('trove_notification' in ctx_dict)
|
||||
self.assertIn('trove_notification', ctx_dict)
|
||||
n_dict = ctx_dict['trove_notification']
|
||||
self.assertThat(n_dict.get('notification_classname'),
|
||||
Equals('trove.common.notification.'
|
||||
|
||||
@@ -168,7 +168,7 @@ class TestTroveCommonTraits(trove_testtools.TestCase):
|
||||
self.assertTrue(notifier().info.called)
|
||||
a, _ = notifier().info.call_args
|
||||
payload = a[2]
|
||||
self.assertTrue('availability_zone' in payload)
|
||||
self.assertIn('availability_zone', payload)
|
||||
|
||||
@patch.object(cfg.CONF, 'get', Mock())
|
||||
@patch.object(rpc, 'get_notifier')
|
||||
@@ -350,11 +350,11 @@ class TestDBaaSNotification(trove_testtools.TestCase):
|
||||
self.assertTrue(notifier().info.called)
|
||||
a, _ = notifier().info.call_args
|
||||
payload = a[2]
|
||||
self.assertTrue('client_ip' in payload)
|
||||
self.assertTrue('request_id' in payload)
|
||||
self.assertTrue('server_type' in payload)
|
||||
self.assertTrue('server_ip' in payload)
|
||||
self.assertTrue('tenant_id' in payload)
|
||||
self.assertIn('client_ip', payload)
|
||||
self.assertIn('request_id', payload)
|
||||
self.assertIn('server_type', payload)
|
||||
self.assertIn('server_ip', payload)
|
||||
self.assertIn('tenant_id', payload)
|
||||
|
||||
@patch.object(rpc, 'get_notifier')
|
||||
def test_verify_required_start_args(self, notifier):
|
||||
@@ -362,9 +362,9 @@ class TestDBaaSNotification(trove_testtools.TestCase):
|
||||
self.assertTrue(notifier().info.called)
|
||||
a, _ = notifier().info.call_args
|
||||
payload = a[2]
|
||||
self.assertTrue('name' in payload)
|
||||
self.assertTrue('flavor_id' in payload)
|
||||
self.assertTrue('datastore' in payload)
|
||||
self.assertIn('name', payload)
|
||||
self.assertIn('flavor_id', payload)
|
||||
self.assertIn('datastore', payload)
|
||||
self.assertTrue('users' not in payload)
|
||||
|
||||
@patch.object(rpc, 'get_notifier')
|
||||
@@ -374,7 +374,7 @@ class TestDBaaSNotification(trove_testtools.TestCase):
|
||||
self.assertTrue(notifier().info.called)
|
||||
a, _ = notifier().info.call_args
|
||||
payload = a[2]
|
||||
self.assertTrue('users' in payload)
|
||||
self.assertIn('users', payload)
|
||||
|
||||
@patch.object(rpc, 'get_notifier')
|
||||
def test_verify_required_end_args(self, notifier):
|
||||
@@ -382,7 +382,7 @@ class TestDBaaSNotification(trove_testtools.TestCase):
|
||||
self.assertTrue(notifier().info.called)
|
||||
a, _ = notifier().info.call_args
|
||||
payload = a[2]
|
||||
self.assertTrue('instance_id' in payload)
|
||||
self.assertIn('instance_id', payload)
|
||||
|
||||
def _test_notify_callback(self, fn, *args, **kwargs):
|
||||
with patch.object(rpc, 'get_notifier') as notifier:
|
||||
|
||||
@@ -245,7 +245,7 @@ class DbaasTest(trove_testtools.TestCase):
|
||||
self.assertEqual(["3306"], options["port"])
|
||||
self.assertEqual(["/usr"], options["basedir"])
|
||||
self.assertEqual(["/tmp"], options["tmpdir"])
|
||||
self.assertTrue("skip-external-locking" in options)
|
||||
self.assertIn("skip-external-locking", options)
|
||||
|
||||
def test_load_mysqld_options_contains_plugin_loads_options(self):
|
||||
output = ("mysqld would've been started with these args:\n"
|
||||
|
||||
@@ -70,28 +70,28 @@ class TestInstanceController(trove_testtools.TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', {'instance': {}})
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('instance' in schema['properties'])
|
||||
self.assertIn('instance', schema['properties'])
|
||||
|
||||
def test_get_schema_action_restart(self):
|
||||
schema = self.controller.get_schema('action', {'restart': {}})
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('restart' in schema['properties'])
|
||||
self.assertIn('restart', schema['properties'])
|
||||
|
||||
def test_get_schema_action_resize_volume(self):
|
||||
schema = self.controller.get_schema(
|
||||
'action', {'resize': {'volume': {}}})
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('resize' in schema['properties'])
|
||||
self.assertTrue(
|
||||
'volume' in schema['properties']['resize']['properties'])
|
||||
self.assertIn('resize', schema['properties'])
|
||||
self.assertIn(
|
||||
'volume', schema['properties']['resize']['properties'])
|
||||
|
||||
def test_get_schema_action_resize_flavorRef(self):
|
||||
schema = self.controller.get_schema(
|
||||
'action', {'resize': {'flavorRef': {}}})
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('resize' in schema['properties'])
|
||||
self.assertTrue(
|
||||
'flavorRef' in schema['properties']['resize']['properties'])
|
||||
self.assertIn('resize', schema['properties'])
|
||||
self.assertIn(
|
||||
'flavorRef', schema['properties']['resize']['properties'])
|
||||
|
||||
def test_get_schema_action_other(self):
|
||||
schema = self.controller.get_schema(
|
||||
|
||||
@@ -73,8 +73,8 @@ class SimpleInstanceTest(trove_testtools.TestCase):
|
||||
ip = filter_ips(
|
||||
ip, CONF.ip_regex, CONF.black_list_regex)
|
||||
self.assertEqual(2, len(ip))
|
||||
self.assertTrue('123.123.123.123' in ip)
|
||||
self.assertTrue('15.123.123.123' in ip)
|
||||
self.assertIn('123.123.123.123', ip)
|
||||
self.assertIn('15.123.123.123', ip)
|
||||
|
||||
def test_filter_ips_black_list(self):
|
||||
CONF.network_label_regex = '.*'
|
||||
@@ -95,16 +95,16 @@ class SimpleInstanceTest(trove_testtools.TestCase):
|
||||
CONF.network_label_regex = '^(private|public)$'
|
||||
ip = self.instance.get_visible_ip_addresses()
|
||||
self.assertEqual(2, len(ip))
|
||||
self.assertTrue('123.123.123.123' in ip)
|
||||
self.assertTrue('15.123.123.123' in ip)
|
||||
self.assertIn('123.123.123.123', ip)
|
||||
self.assertIn('15.123.123.123', ip)
|
||||
|
||||
def test_all_network_labels(self):
|
||||
CONF.network_label_regex = '.*'
|
||||
ip = self.instance.get_visible_ip_addresses()
|
||||
self.assertEqual(3, len(ip))
|
||||
self.assertTrue('10.123.123.123' in ip)
|
||||
self.assertTrue('123.123.123.123' in ip)
|
||||
self.assertTrue('15.123.123.123' in ip)
|
||||
self.assertIn('10.123.123.123', ip)
|
||||
self.assertIn('123.123.123.123', ip)
|
||||
self.assertIn('15.123.123.123', ip)
|
||||
|
||||
def test_locality(self):
|
||||
self.assertEqual('affinity', self.instance.locality)
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestDatastoreVersionController(trove_testtools.TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', self.version)
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('version' in schema['properties'])
|
||||
self.assertIn('version', schema['properties'])
|
||||
|
||||
def test_validate_create(self):
|
||||
body = self.version
|
||||
|
||||
@@ -134,7 +134,7 @@ class TestNotificationTransformer(MockMgmtInstanceTest):
|
||||
self.assertThat(payload['audit_period_beginning'],
|
||||
Not(Is(None)))
|
||||
self.assertThat(payload['audit_period_ending'], Not(Is(None)))
|
||||
self.assertTrue(status.lower() in [db['state'] for db in payloads])
|
||||
self.assertIn(status.lower(), [db['state'] for db in payloads])
|
||||
self.addCleanup(self.do_cleanup, instance, service_status)
|
||||
|
||||
def test_get_service_id(self):
|
||||
|
||||
@@ -49,7 +49,7 @@ class TestModuleController(trove_testtools.TestCase):
|
||||
def test_get_schema_create(self):
|
||||
schema = self.controller.get_schema('create', {'module': {}})
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertTrue('module' in schema['properties'])
|
||||
self.assertIn('module', schema['properties'])
|
||||
|
||||
def test_validate_create_complete(self):
|
||||
body = self.module
|
||||
|
||||
@@ -30,17 +30,17 @@ class TestUserController(trove_testtools.TestCase):
|
||||
def test_get_create_schema(self):
|
||||
body = {'users': [{'name': 'test', 'password': 'test'}]}
|
||||
schema = self.controller.get_schema('create', body)
|
||||
self.assertTrue('users' in schema['properties'])
|
||||
self.assertIn('users', schema['properties'])
|
||||
|
||||
def test_get_update_user_pw(self):
|
||||
body = {'users': [{'name': 'test', 'password': 'test'}]}
|
||||
schema = self.controller.get_schema('update_all', body)
|
||||
self.assertTrue('users' in schema['properties'])
|
||||
self.assertIn('users', schema['properties'])
|
||||
|
||||
def test_get_update_user_db(self):
|
||||
body = {'databases': [{'name': 'test'}, {'name': 'test'}]}
|
||||
schema = self.controller.get_schema('update_all', body)
|
||||
self.assertTrue('databases' in schema['properties'])
|
||||
self.assertIn('databases', schema['properties'])
|
||||
|
||||
def test_validate_create_empty(self):
|
||||
body = {"users": []}
|
||||
@@ -259,7 +259,7 @@ class TestUserController(trove_testtools.TestCase):
|
||||
def test_get_update_user_attributes(self):
|
||||
body = {'user': {'name': 'test'}}
|
||||
schema = self.controller.get_schema('update', body)
|
||||
self.assertTrue('user' in schema['properties'])
|
||||
self.assertIn('user', schema['properties'])
|
||||
|
||||
def test_validate_update_user_attributes(self):
|
||||
body = {'user': {'name': 'test', 'password': 'test', 'host': '%'}}
|
||||
@@ -353,6 +353,6 @@ class TestSchemaController(trove_testtools.TestCase):
|
||||
body = {"databases": []}
|
||||
schema = self.controller.get_schema('create', body)
|
||||
self.assertNotEqual(schema, None)
|
||||
self.assertTrue('databases' in body)
|
||||
self.assertIn('databases', body)
|
||||
validator = jsonschema.Draft4Validator(schema)
|
||||
self.assertTrue(validator.is_valid(body))
|
||||
|
||||
@@ -120,7 +120,7 @@ class QuotaControllerTest(trove_testtools.TestCase):
|
||||
result = self.controller.update(self.req, body, FAKE_TENANT1,
|
||||
FAKE_TENANT2)
|
||||
self.assertEqual(1, instance_quota.save.call_count)
|
||||
self.assertTrue('instances' in result._data['quotas'])
|
||||
self.assertIn('instances', result._data['quotas'])
|
||||
self.assertEqual(200, result.status)
|
||||
self.assertEqual(2, result._data['quotas']['instances'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user