summaryrefslogtreecommitdiff
path: root/trove
diff options
context:
space:
mode:
authorBin Zhou <zhou.bin9@zte.com.cn>2016-09-02 12:38:40 +0800
committerBin Zhou <zhou.bin9@zte.com.cn>2016-09-12 03:36:20 +0000
commit9101308914ff2eb8e52e986062468f7953037d53 (patch)
tree8b798e170c865dd3ca2e6b19b14681336a4d75b2 /trove
parent4b56d80e6391c25096e59f50e2fa90cc87b14e11 (diff)
downloadtrove-9101308914ff2eb8e52e986062468f7953037d53.tar.gz
Use assertIn instead of assertTrue(A in B)
Developers should use assertIn(A, B) instead of assertTrue(A in B ). TrivialFix Change-Id: I31e20fae988b71145ec7b82fa696a87c4dbcc4e3
Diffstat (limited to 'trove')
-rw-r--r--trove/tests/unittests/api/common/test_limits.py4
-rw-r--r--trove/tests/unittests/cluster/test_cluster_controller.py4
-rw-r--r--trove/tests/unittests/cluster/test_cluster_pxc_controller.py2
-rw-r--r--trove/tests/unittests/cluster/test_cluster_redis_controller.py2
-rw-r--r--trove/tests/unittests/cluster/test_cluster_vertica_controller.py2
-rw-r--r--trove/tests/unittests/common/test_context.py2
-rw-r--r--trove/tests/unittests/common/test_notification.py22
-rw-r--r--trove/tests/unittests/guestagent/test_dbaas.py2
-rw-r--r--trove/tests/unittests/instance/test_instance_controller.py16
-rw-r--r--trove/tests/unittests/instance/test_instance_models.py14
-rw-r--r--trove/tests/unittests/mgmt/test_datastore_controller.py2
-rw-r--r--trove/tests/unittests/mgmt/test_models.py2
-rw-r--r--trove/tests/unittests/module/test_module_controller.py2
-rw-r--r--trove/tests/unittests/mysql/test_user_controller.py10
-rw-r--r--trove/tests/unittests/quota/test_quota.py2
15 files changed, 44 insertions, 44 deletions
diff --git a/trove/tests/unittests/api/common/test_limits.py b/trove/tests/unittests/api/common/test_limits.py
index 03c8219f..5757f5a4 100644
--- a/trove/tests/unittests/api/common/test_limits.py
+++ b/trove/tests/unittests/api/common/test_limits.py
@@ -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)
diff --git a/trove/tests/unittests/cluster/test_cluster_controller.py b/trove/tests/unittests/cluster/test_cluster_controller.py
index f76eba39..73979ed8 100644
--- a/trove/tests/unittests/cluster/test_cluster_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_controller.py
@@ -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
diff --git a/trove/tests/unittests/cluster/test_cluster_pxc_controller.py b/trove/tests/unittests/cluster/test_cluster_pxc_controller.py
index b9599375..2c6f5798 100644
--- a/trove/tests/unittests/cluster/test_cluster_pxc_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_pxc_controller.py
@@ -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):
diff --git a/trove/tests/unittests/cluster/test_cluster_redis_controller.py b/trove/tests/unittests/cluster/test_cluster_redis_controller.py
index 1732be03..e6c05130 100644
--- a/trove/tests/unittests/cluster/test_cluster_redis_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_redis_controller.py
@@ -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):
diff --git a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py
index bbfc729f..fa772eed 100644
--- a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py
@@ -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):
diff --git a/trove/tests/unittests/common/test_context.py b/trove/tests/unittests/common/test_context.py
index ce55281c..f49a7a18 100644
--- a/trove/tests/unittests/common/test_context.py
+++ b/trove/tests/unittests/common/test_context.py
@@ -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.'
diff --git a/trove/tests/unittests/common/test_notification.py b/trove/tests/unittests/common/test_notification.py
index 9d617811..9685c0e1 100644
--- a/trove/tests/unittests/common/test_notification.py
+++ b/trove/tests/unittests/common/test_notification.py
@@ -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:
diff --git a/trove/tests/unittests/guestagent/test_dbaas.py b/trove/tests/unittests/guestagent/test_dbaas.py
index 9f1559eb..c063f4c2 100644
--- a/trove/tests/unittests/guestagent/test_dbaas.py
+++ b/trove/tests/unittests/guestagent/test_dbaas.py
@@ -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"
diff --git a/trove/tests/unittests/instance/test_instance_controller.py b/trove/tests/unittests/instance/test_instance_controller.py
index fae44f1b..cbd820bc 100644
--- a/trove/tests/unittests/instance/test_instance_controller.py
+++ b/trove/tests/unittests/instance/test_instance_controller.py
@@ -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(
diff --git a/trove/tests/unittests/instance/test_instance_models.py b/trove/tests/unittests/instance/test_instance_models.py
index f39b9e8d..d7b642b5 100644
--- a/trove/tests/unittests/instance/test_instance_models.py
+++ b/trove/tests/unittests/instance/test_instance_models.py
@@ -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)
diff --git a/trove/tests/unittests/mgmt/test_datastore_controller.py b/trove/tests/unittests/mgmt/test_datastore_controller.py
index 92d11e3d..d24cf1f8 100644
--- a/trove/tests/unittests/mgmt/test_datastore_controller.py
+++ b/trove/tests/unittests/mgmt/test_datastore_controller.py
@@ -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
diff --git a/trove/tests/unittests/mgmt/test_models.py b/trove/tests/unittests/mgmt/test_models.py
index 648fca39..e83327dd 100644
--- a/trove/tests/unittests/mgmt/test_models.py
+++ b/trove/tests/unittests/mgmt/test_models.py
@@ -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):
diff --git a/trove/tests/unittests/module/test_module_controller.py b/trove/tests/unittests/module/test_module_controller.py
index 08c6d7d7..2a8069d8 100644
--- a/trove/tests/unittests/module/test_module_controller.py
+++ b/trove/tests/unittests/module/test_module_controller.py
@@ -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
diff --git a/trove/tests/unittests/mysql/test_user_controller.py b/trove/tests/unittests/mysql/test_user_controller.py
index b14f508f..75700cec 100644
--- a/trove/tests/unittests/mysql/test_user_controller.py
+++ b/trove/tests/unittests/mysql/test_user_controller.py
@@ -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))
diff --git a/trove/tests/unittests/quota/test_quota.py b/trove/tests/unittests/quota/test_quota.py
index 39638f4e..ac63d132 100644
--- a/trove/tests/unittests/quota/test_quota.py
+++ b/trove/tests/unittests/quota/test_quota.py
@@ -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'])