Cleanup in asserts in python-novaclient

The following replacements were done:

1) assertEqual(True, *) -> assertTrue(*)
2) assertEqual(False, *) -> assertFalse(*)
3) assertTrue(a in b) -> assertIn(a, b)
4) assertTrue(* is not None) -> assertIsNotNone(*)

TrivialFix

Change-Id: I8d8a2d7b5d3505e07728544b683b301d1a8850cf
changes/74/160774/1
Pavel Kholkin 8 years ago
parent 9f4d64a1bf
commit 560eeafb6d
  1. 16
      novaclient/tests/unit/test_client.py
  2. 2
      novaclient/tests/unit/test_utils.py
  3. 4
      novaclient/tests/unit/v2/test_flavors.py
  4. 4
      novaclient/tests/unit/v2/test_fping.py
  5. 6
      novaclient/tests/unit/v2/test_limits.py
  6. 10
      novaclient/tests/unit/v2/test_servers.py

@ -161,26 +161,26 @@ class ClientTest(utils.TestCase):
def test_client_with_os_cache_enabled(self):
cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", os_cache=True)
self.assertEqual(True, cs.os_cache)
self.assertEqual(True, cs.client.os_cache)
self.assertTrue(cs.os_cache)
self.assertTrue(cs.client.os_cache)
def test_client_with_os_cache_disabled(self):
cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", os_cache=False)
self.assertEqual(False, cs.os_cache)
self.assertEqual(False, cs.client.os_cache)
self.assertFalse(cs.os_cache)
self.assertFalse(cs.client.os_cache)
def test_client_with_no_cache_enabled(self):
cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", no_cache=True)
self.assertEqual(False, cs.os_cache)
self.assertEqual(False, cs.client.os_cache)
self.assertFalse(cs.os_cache)
self.assertFalse(cs.client.os_cache)
def test_client_with_no_cache_disabled(self):
cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", no_cache=False)
self.assertEqual(True, cs.os_cache)
self.assertEqual(True, cs.client.os_cache)
self.assertTrue(cs.os_cache)
self.assertTrue(cs.client.os_cache)
def test_client_set_management_url_v1_1(self):
cs = novaclient.v2.client.Client("user", "password", "project_id",

@ -311,7 +311,7 @@ class ValidationsTestCase(test_utils.TestCase):
utils.validate_flavor_metadata_keys([key])
self.fail("Invalid key passed validation: %s" % key)
except exceptions.CommandError as ce:
self.assertTrue(key in str(ce))
self.assertIn(key, str(ce))
class ResourceManagerExtraKwargsHookTestCase(test_utils.TestCase):

@ -70,7 +70,7 @@ class FlavorsTest(utils.TestCase):
self.assertEqual(256, f.ram)
self.assertEqual(10, f.disk)
self.assertEqual(10, f.ephemeral)
self.assertEqual(True, f.is_public)
self.assertTrue(f.is_public)
def test_get_flavor_details_alphanum_id(self):
f = self.cs.flavors.get('aa1')
@ -79,7 +79,7 @@ class FlavorsTest(utils.TestCase):
self.assertEqual(128, f.ram)
self.assertEqual(0, f.disk)
self.assertEqual(0, f.ephemeral)
self.assertEqual(True, f.is_public)
self.assertTrue(f.is_public)
def test_get_flavor_details_diablo(self):
f = self.cs.flavors.get(3)

@ -34,7 +34,7 @@ class FpingTest(utils.FixturedTestCase):
for f in fl:
self.assertIsInstance(f, fping.Fping)
self.assertEqual("fake-project", f.project_id)
self.assertEqual(True, f.alive)
self.assertTrue(f.alive)
def test_list_fpings_all_tenants(self):
fl = self.cs.fping.list(all_tenants=True)
@ -59,4 +59,4 @@ class FpingTest(utils.FixturedTestCase):
self.assert_called('GET', '/os-fping/1')
self.assertIsInstance(f, fping.Fping)
self.assertEqual("fake-project", f.project_id)
self.assertEqual(True, f.alive)
self.assertTrue(f.alive)

@ -47,7 +47,7 @@ class LimitsTest(utils.FixturedTestCase):
self.assertEqual(len(abs_limits), len(expected))
for limit in abs_limits:
self.assertTrue(limit in expected)
self.assertIn(limit, expected)
def test_absolute_limits_reserved(self):
obj = self.cs.limits.get(reserved=True)
@ -65,7 +65,7 @@ class LimitsTest(utils.FixturedTestCase):
self.assertEqual(len(abs_limits), len(expected))
for limit in abs_limits:
self.assertTrue(limit in expected)
self.assertIn(limit, expected)
def test_rate_limits(self):
obj = self.cs.limits.get()
@ -85,4 +85,4 @@ class LimitsTest(utils.FixturedTestCase):
self.assertEqual(len(rate_limits), len(expected))
for limit in rate_limits:
self.assertTrue(limit in expected)
self.assertIn(limit, expected)

@ -212,7 +212,7 @@ class ServersTest(utils.FixturedTestCase):
# verify disk config param was used in the request:
body = jsonutils.loads(self.requests.last_request.body)
server = body['server']
self.assertTrue('OS-DCF:diskConfig' in server)
self.assertIn('OS-DCF:diskConfig', server)
self.assertEqual(disk_config, server['OS-DCF:diskConfig'])
def test_create_server_disk_config_auto(self):
@ -302,7 +302,7 @@ class ServersTest(utils.FixturedTestCase):
body = jsonutils.loads(self.requests.last_request.body)
d = body[operation]
self.assertTrue('OS-DCF:diskConfig' in d)
self.assertIn('OS-DCF:diskConfig', d)
self.assertEqual(disk_config, d['OS-DCF:diskConfig'])
def test_rebuild_server_disk_config_auto(self):
@ -318,7 +318,7 @@ class ServersTest(utils.FixturedTestCase):
body = jsonutils.loads(self.requests.last_request.body)
d = body['rebuild']
self.assertIn('preserve_ephemeral', d)
self.assertEqual(True, d['preserve_ephemeral'])
self.assertTrue(d['preserve_ephemeral'])
def test_rebuild_server_name_meta_files(self):
files = {'/etc/passwd': 'some data'}
@ -560,11 +560,11 @@ class ServersTest(utils.FixturedTestCase):
def test_get_server_diagnostics(self):
s = self.cs.servers.get(1234)
diagnostics = s.diagnostics()
self.assertTrue(diagnostics is not None)
self.assertIsNotNone(diagnostics)
self.assert_called('GET', '/servers/1234/diagnostics')
diagnostics_from_manager = self.cs.servers.diagnostics(1234)
self.assertTrue(diagnostics_from_manager is not None)
self.assertIsNotNone(diagnostics_from_manager)
self.assert_called('GET', '/servers/1234/diagnostics')
self.assertEqual(diagnostics[1], diagnostics_from_manager[1])

Loading…
Cancel
Save