assertTrue(isinstance) replace by assertIsInstance

some of tests use different method of assertTrue(isinstance(A, B))
or assertEqual(type(A), B). The correct way is to use
assertIsInstance(A, B) provided by testtools

Closes-Bug: #1268480
Change-Id: Ie3b3e49ea3cc4357a65605ad54ff4ee1fbde12c7
This commit is contained in:
lizheming 2014-01-15 10:42:19 +08:00
parent 1a20d2964d
commit 40e433469d
29 changed files with 135 additions and 137 deletions

View File

@ -186,8 +186,8 @@ class ClientTest(utils.TestCase):
cs = novaclient.v3.client.Client("user", "password", "project_id", cs = novaclient.v3.client.Client("user", "password", "project_id",
auth_url="foo/v2", auth_url="foo/v2",
extensions=extensions) extensions=extensions)
self.assertTrue(isinstance(getattr(cs, fake_attribute_name1, None), self.assertIsInstance(getattr(cs, fake_attribute_name1, None),
fakes.FakeManager)) fakes.FakeManager)
self.assertFalse(hasattr(cs, fake_attribute_name2)) self.assertFalse(hasattr(cs, fake_attribute_name2))
@mock.patch.object(novaclient.client.HTTPClient, 'authenticate') @mock.patch.object(novaclient.client.HTTPClient, 'authenticate')

View File

@ -33,18 +33,18 @@ class BaremetalExtensionTest(utils.TestCase):
nl = cs.baremetal.list() nl = cs.baremetal.list()
cs.assert_called('GET', '/os-baremetal-nodes') cs.assert_called('GET', '/os-baremetal-nodes')
for n in nl: for n in nl:
self.assertTrue(isinstance(n, baremetal.BareMetalNode)) self.assertIsInstance(n, baremetal.BareMetalNode)
def test_get_node(self): def test_get_node(self):
n = cs.baremetal.get(1) n = cs.baremetal.get(1)
cs.assert_called('GET', '/os-baremetal-nodes/1') cs.assert_called('GET', '/os-baremetal-nodes/1')
self.assertTrue(isinstance(n, baremetal.BareMetalNode)) self.assertIsInstance(n, baremetal.BareMetalNode)
def test_create_node(self): def test_create_node(self):
n = cs.baremetal.create("service_host", 1, 1024, 2048, n = cs.baremetal.create("service_host", 1, 1024, 2048,
"aa:bb:cc:dd:ee:ff") "aa:bb:cc:dd:ee:ff")
cs.assert_called('POST', '/os-baremetal-nodes') cs.assert_called('POST', '/os-baremetal-nodes')
self.assertTrue(isinstance(n, baremetal.BareMetalNode)) self.assertIsInstance(n, baremetal.BareMetalNode)
def test_delete_node(self): def test_delete_node(self):
n = cs.baremetal.get(1) n = cs.baremetal.get(1)
@ -54,7 +54,7 @@ class BaremetalExtensionTest(utils.TestCase):
def test_node_add_interface(self): def test_node_add_interface(self):
i = cs.baremetal.add_interface(1, "bb:cc:dd:ee:ff:aa", 1, 2) i = cs.baremetal.add_interface(1, "bb:cc:dd:ee:ff:aa", 1, 2)
cs.assert_called('POST', '/os-baremetal-nodes/1/action') cs.assert_called('POST', '/os-baremetal-nodes/1/action')
self.assertTrue(isinstance(i, baremetal.BareMetalNodeInterface)) self.assertIsInstance(i, baremetal.BareMetalNodeInterface)
def test_node_remove_interface(self): def test_node_remove_interface(self):
cs.baremetal.remove_interface(1, "bb:cc:dd:ee:ff:aa") cs.baremetal.remove_interface(1, "bb:cc:dd:ee:ff:aa")

View File

@ -28,7 +28,7 @@ class MigrationsTest(utils.TestCase):
ml = cs.migrations.list() ml = cs.migrations.list()
cs.assert_called('GET', '/os-migrations') cs.assert_called('GET', '/os-migrations')
for m in ml: for m in ml:
self.assertTrue(isinstance(m, migrations.Migration)) self.assertIsInstance(m, migrations.Migration)
def test_list_migrations_with_filters(self): def test_list_migrations_with_filters(self):
ml = cs.migrations.list('host1', 'finished', 'child1') ml = cs.migrations.list('host1', 'finished', 'child1')
@ -37,4 +37,4 @@ class MigrationsTest(utils.TestCase):
'/os-migrations?cell_name=child1&host=host1' '/os-migrations?cell_name=child1&host=host1'
'&status=finished') '&status=finished')
for m in ml: for m in ml:
self.assertTrue(isinstance(m, migrations.Migration)) self.assertIsInstance(m, migrations.Migration)

View File

@ -34,14 +34,14 @@ class AgentsTest(utils.TestCase):
ags = self.cs.agents.list() ags = self.cs.agents.list()
self.cs.assert_called('GET', '/os-agents') self.cs.assert_called('GET', '/os-agents')
for a in ags: for a in ags:
self.assertTrue(isinstance(a, self.agent_type)) self.assertIsInstance(a, self.agent_type)
self.assertEqual(a.hypervisor, 'kvm') self.assertEqual(a.hypervisor, 'kvm')
def test_list_agents_with_hypervisor(self): def test_list_agents_with_hypervisor(self):
ags = self.cs.agents.list('xen') ags = self.cs.agents.list('xen')
self.cs.assert_called('GET', '/os-agents?hypervisor=xen') self.cs.assert_called('GET', '/os-agents?hypervisor=xen')
for a in ags: for a in ags:
self.assertTrue(isinstance(a, self.agent_type)) self.assertIsInstance(a, self.agent_type)
self.assertEqual(a.hypervisor, 'xen') self.assertEqual(a.hypervisor, 'xen')
def test_agents_create(self): def test_agents_create(self):

View File

@ -34,31 +34,31 @@ class AggregatesTest(utils.TestCase):
result = self.cs.aggregates.list() result = self.cs.aggregates.list()
self.cs.assert_called('GET', '/os-aggregates') self.cs.assert_called('GET', '/os-aggregates')
for aggregate in result: for aggregate in result:
self.assertTrue(isinstance(aggregate, aggregates.Aggregate)) self.assertIsInstance(aggregate, aggregates.Aggregate)
def test_create_aggregate(self): def test_create_aggregate(self):
body = {"aggregate": {"name": "test", "availability_zone": "nova1"}} body = {"aggregate": {"name": "test", "availability_zone": "nova1"}}
aggregate = self.cs.aggregates.create("test", "nova1") aggregate = self.cs.aggregates.create("test", "nova1")
self.cs.assert_called('POST', '/os-aggregates', body) self.cs.assert_called('POST', '/os-aggregates', body)
self.assertTrue(isinstance(aggregate, aggregates.Aggregate)) self.assertIsInstance(aggregate, aggregates.Aggregate)
def test_get(self): def test_get(self):
aggregate = self.cs.aggregates.get("1") aggregate = self.cs.aggregates.get("1")
self.cs.assert_called('GET', '/os-aggregates/1') self.cs.assert_called('GET', '/os-aggregates/1')
self.assertTrue(isinstance(aggregate, aggregates.Aggregate)) self.assertIsInstance(aggregate, aggregates.Aggregate)
aggregate2 = self.cs.aggregates.get(aggregate) aggregate2 = self.cs.aggregates.get(aggregate)
self.cs.assert_called('GET', '/os-aggregates/1') self.cs.assert_called('GET', '/os-aggregates/1')
self.assertTrue(isinstance(aggregate2, aggregates.Aggregate)) self.assertIsInstance(aggregate2, aggregates.Aggregate)
def test_get_details(self): def test_get_details(self):
aggregate = self.cs.aggregates.get_details("1") aggregate = self.cs.aggregates.get_details("1")
self.cs.assert_called('GET', '/os-aggregates/1') self.cs.assert_called('GET', '/os-aggregates/1')
self.assertTrue(isinstance(aggregate, aggregates.Aggregate)) self.assertIsInstance(aggregate, aggregates.Aggregate)
aggregate2 = self.cs.aggregates.get_details(aggregate) aggregate2 = self.cs.aggregates.get_details(aggregate)
self.cs.assert_called('GET', '/os-aggregates/1') self.cs.assert_called('GET', '/os-aggregates/1')
self.assertTrue(isinstance(aggregate2, aggregates.Aggregate)) self.assertIsInstance(aggregate2, aggregates.Aggregate)
def test_update(self): def test_update(self):
aggregate = self.cs.aggregates.get("1") aggregate = self.cs.aggregates.get("1")
@ -67,11 +67,11 @@ class AggregatesTest(utils.TestCase):
result1 = aggregate.update(values) result1 = aggregate.update(values)
self.cs.assert_called('PUT', '/os-aggregates/1', body) self.cs.assert_called('PUT', '/os-aggregates/1', body)
self.assertTrue(isinstance(result1, aggregates.Aggregate)) self.assertIsInstance(result1, aggregates.Aggregate)
result2 = self.cs.aggregates.update(2, values) result2 = self.cs.aggregates.update(2, values)
self.cs.assert_called('PUT', '/os-aggregates/2', body) self.cs.assert_called('PUT', '/os-aggregates/2', body)
self.assertTrue(isinstance(result2, aggregates.Aggregate)) self.assertIsInstance(result2, aggregates.Aggregate)
def test_update_with_availability_zone(self): def test_update_with_availability_zone(self):
aggregate = self.cs.aggregates.get("1") aggregate = self.cs.aggregates.get("1")
@ -80,7 +80,7 @@ class AggregatesTest(utils.TestCase):
result3 = self.cs.aggregates.update(aggregate, values) result3 = self.cs.aggregates.update(aggregate, values)
self.cs.assert_called('PUT', '/os-aggregates/1', body) self.cs.assert_called('PUT', '/os-aggregates/1', body)
self.assertTrue(isinstance(result3, aggregates.Aggregate)) self.assertIsInstance(result3, aggregates.Aggregate)
def test_add_host(self): def test_add_host(self):
aggregate = self.cs.aggregates.get("1") aggregate = self.cs.aggregates.get("1")
@ -89,15 +89,15 @@ class AggregatesTest(utils.TestCase):
result1 = aggregate.add_host(host) result1 = aggregate.add_host(host)
self.cs.assert_called('POST', '/os-aggregates/1/action', body) self.cs.assert_called('POST', '/os-aggregates/1/action', body)
self.assertTrue(isinstance(result1, aggregates.Aggregate)) self.assertIsInstance(result1, aggregates.Aggregate)
result2 = self.cs.aggregates.add_host("2", host) result2 = self.cs.aggregates.add_host("2", host)
self.cs.assert_called('POST', '/os-aggregates/2/action', body) self.cs.assert_called('POST', '/os-aggregates/2/action', body)
self.assertTrue(isinstance(result2, aggregates.Aggregate)) self.assertIsInstance(result2, aggregates.Aggregate)
result3 = self.cs.aggregates.add_host(aggregate, host) result3 = self.cs.aggregates.add_host(aggregate, host)
self.cs.assert_called('POST', '/os-aggregates/1/action', body) self.cs.assert_called('POST', '/os-aggregates/1/action', body)
self.assertTrue(isinstance(result3, aggregates.Aggregate)) self.assertIsInstance(result3, aggregates.Aggregate)
def test_remove_host(self): def test_remove_host(self):
aggregate = self.cs.aggregates.get("1") aggregate = self.cs.aggregates.get("1")
@ -106,15 +106,15 @@ class AggregatesTest(utils.TestCase):
result1 = aggregate.remove_host(host) result1 = aggregate.remove_host(host)
self.cs.assert_called('POST', '/os-aggregates/1/action', body) self.cs.assert_called('POST', '/os-aggregates/1/action', body)
self.assertTrue(isinstance(result1, aggregates.Aggregate)) self.assertIsInstance(result1, aggregates.Aggregate)
result2 = self.cs.aggregates.remove_host("2", host) result2 = self.cs.aggregates.remove_host("2", host)
self.cs.assert_called('POST', '/os-aggregates/2/action', body) self.cs.assert_called('POST', '/os-aggregates/2/action', body)
self.assertTrue(isinstance(result2, aggregates.Aggregate)) self.assertIsInstance(result2, aggregates.Aggregate)
result3 = self.cs.aggregates.remove_host(aggregate, host) result3 = self.cs.aggregates.remove_host(aggregate, host)
self.cs.assert_called('POST', '/os-aggregates/1/action', body) self.cs.assert_called('POST', '/os-aggregates/1/action', body)
self.assertTrue(isinstance(result3, aggregates.Aggregate)) self.assertIsInstance(result3, aggregates.Aggregate)
def test_set_metadata(self): def test_set_metadata(self):
aggregate = self.cs.aggregates.get("1") aggregate = self.cs.aggregates.get("1")
@ -123,15 +123,15 @@ class AggregatesTest(utils.TestCase):
result1 = aggregate.set_metadata(metadata) result1 = aggregate.set_metadata(metadata)
self.cs.assert_called('POST', '/os-aggregates/1/action', body) self.cs.assert_called('POST', '/os-aggregates/1/action', body)
self.assertTrue(isinstance(result1, aggregates.Aggregate)) self.assertIsInstance(result1, aggregates.Aggregate)
result2 = self.cs.aggregates.set_metadata(2, metadata) result2 = self.cs.aggregates.set_metadata(2, metadata)
self.cs.assert_called('POST', '/os-aggregates/2/action', body) self.cs.assert_called('POST', '/os-aggregates/2/action', body)
self.assertTrue(isinstance(result2, aggregates.Aggregate)) self.assertIsInstance(result2, aggregates.Aggregate)
result3 = self.cs.aggregates.set_metadata(aggregate, metadata) result3 = self.cs.aggregates.set_metadata(aggregate, metadata)
self.cs.assert_called('POST', '/os-aggregates/1/action', body) self.cs.assert_called('POST', '/os-aggregates/1/action', body)
self.assertTrue(isinstance(result3, aggregates.Aggregate)) self.assertIsInstance(result3, aggregates.Aggregate)
def test_delete_aggregate(self): def test_delete_aggregate(self):
aggregate = self.cs.aggregates.list()[0] aggregate = self.cs.aggregates.list()[0]

View File

@ -46,8 +46,7 @@ class AvailabilityZoneTest(utils.TestCase):
self.cs.assert_called('GET', '/os-availability-zone') self.cs.assert_called('GET', '/os-availability-zone')
for zone in zones: for zone in zones:
self.assertTrue(isinstance(zone, self.assertIsInstance(zone, self.availability_zone_type)
self.availability_zone_type))
self.assertEqual(2, len(zones)) self.assertEqual(2, len(zones))
@ -67,8 +66,7 @@ class AvailabilityZoneTest(utils.TestCase):
self.cs.assert_called('GET', '/os-availability-zone/detail') self.cs.assert_called('GET', '/os-availability-zone/detail')
for zone in zones: for zone in zones:
self.assertTrue(isinstance(zone, self.assertIsInstance(zone, self.availability_zone_type)
self.availability_zone_type))
self.assertEqual(3, len(zones)) self.assertEqual(3, len(zones))

View File

@ -31,9 +31,9 @@ class CertsTest(utils.TestCase):
def test_create_cert(self): def test_create_cert(self):
cert = self.cs.certs.create() cert = self.cs.certs.create()
self.cs.assert_called('POST', '/os-certificates') self.cs.assert_called('POST', '/os-certificates')
self.assertTrue(isinstance(cert, certs.Certificate)) self.assertIsInstance(cert, certs.Certificate)
def test_get_root_cert(self): def test_get_root_cert(self):
cert = self.cs.certs.get() cert = self.cs.certs.get()
self.cs.assert_called('GET', '/os-certificates/root') self.cs.assert_called('GET', '/os-certificates/root')
self.assertTrue(isinstance(cert, certs.Certificate)) self.assertIsInstance(cert, certs.Certificate)

View File

@ -24,14 +24,14 @@ class CloudpipeTest(utils.TestCase):
def test_list_cloudpipes(self): def test_list_cloudpipes(self):
cp = cs.cloudpipe.list() cp = cs.cloudpipe.list()
cs.assert_called('GET', '/os-cloudpipe') cs.assert_called('GET', '/os-cloudpipe')
[self.assertTrue(isinstance(c, cloudpipe.Cloudpipe)) for c in cp] [self.assertIsInstance(c, cloudpipe.Cloudpipe) for c in cp]
def test_create(self): def test_create(self):
project = "test" project = "test"
cp = cs.cloudpipe.create(project) cp = cs.cloudpipe.create(project)
body = {'cloudpipe': {'project_id': project}} body = {'cloudpipe': {'project_id': project}}
cs.assert_called('POST', '/os-cloudpipe', body) cs.assert_called('POST', '/os-cloudpipe', body)
self.assertTrue(isinstance(cp, str)) self.assertIsInstance(cp, str)
def test_update(self): def test_update(self):
cs.cloudpipe.update("192.168.1.1", 2345) cs.cloudpipe.update("192.168.1.1", 2345)

View File

@ -27,7 +27,7 @@ class FlavorAccessTest(utils.TestCase):
kwargs = {'flavor': cs.flavors.get(2)} kwargs = {'flavor': cs.flavors.get(2)}
r = cs.flavor_access.list(**kwargs) r = cs.flavor_access.list(**kwargs)
cs.assert_called('GET', '/flavors/2/os-flavor-access') cs.assert_called('GET', '/flavors/2/os-flavor-access')
[self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r] [self.assertIsInstance(a, flavor_access.FlavorAccess) for a in r]
def test_add_tenant_access(self): def test_add_tenant_access(self):
flavor = cs.flavors.get(2) flavor = cs.flavors.get(2)
@ -41,7 +41,7 @@ class FlavorAccessTest(utils.TestCase):
} }
cs.assert_called('POST', '/flavors/2/action', body) cs.assert_called('POST', '/flavors/2/action', body)
[self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r] [self.assertIsInstance(a, flavor_access.FlavorAccess) for a in r]
def test_remove_tenant_access(self): def test_remove_tenant_access(self):
flavor = cs.flavors.get(2) flavor = cs.flavors.get(2)
@ -55,4 +55,4 @@ class FlavorAccessTest(utils.TestCase):
} }
cs.assert_called('POST', '/flavors/2/action', body) cs.assert_called('POST', '/flavors/2/action', body)
[self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r] [self.assertIsInstance(a, flavor_access.FlavorAccess) for a in r]

View File

@ -35,36 +35,36 @@ class FlavorsTest(utils.TestCase):
fl = self.cs.flavors.list() fl = self.cs.flavors.list()
self.cs.assert_called('GET', '/flavors/detail') self.cs.assert_called('GET', '/flavors/detail')
for flavor in fl: for flavor in fl:
self.assertTrue(isinstance(flavor, self.flavor_type)) self.assertIsInstance(flavor, self.flavor_type)
def test_list_flavors_undetailed(self): def test_list_flavors_undetailed(self):
fl = self.cs.flavors.list(detailed=False) fl = self.cs.flavors.list(detailed=False)
self.cs.assert_called('GET', '/flavors') self.cs.assert_called('GET', '/flavors')
for flavor in fl: for flavor in fl:
self.assertTrue(isinstance(flavor, self.flavor_type)) self.assertIsInstance(flavor, self.flavor_type)
def test_list_flavors_is_public_none(self): def test_list_flavors_is_public_none(self):
fl = self.cs.flavors.list(is_public=None) fl = self.cs.flavors.list(is_public=None)
self.cs.assert_called('GET', '/flavors/detail?is_public=None') self.cs.assert_called('GET', '/flavors/detail?is_public=None')
for flavor in fl: for flavor in fl:
self.assertTrue(isinstance(flavor, self.flavor_type)) self.assertIsInstance(flavor, self.flavor_type)
def test_list_flavors_is_public_false(self): def test_list_flavors_is_public_false(self):
fl = self.cs.flavors.list(is_public=False) fl = self.cs.flavors.list(is_public=False)
self.cs.assert_called('GET', '/flavors/detail?is_public=False') self.cs.assert_called('GET', '/flavors/detail?is_public=False')
for flavor in fl: for flavor in fl:
self.assertTrue(isinstance(flavor, self.flavor_type)) self.assertIsInstance(flavor, self.flavor_type)
def test_list_flavors_is_public_true(self): def test_list_flavors_is_public_true(self):
fl = self.cs.flavors.list(is_public=True) fl = self.cs.flavors.list(is_public=True)
self.cs.assert_called('GET', '/flavors/detail') self.cs.assert_called('GET', '/flavors/detail')
for flavor in fl: for flavor in fl:
self.assertTrue(isinstance(flavor, self.flavor_type)) self.assertIsInstance(flavor, self.flavor_type)
def test_get_flavor_details(self): def test_get_flavor_details(self):
f = self.cs.flavors.get(1) f = self.cs.flavors.get(1)
self.cs.assert_called('GET', '/flavors/1') self.cs.assert_called('GET', '/flavors/1')
self.assertTrue(isinstance(f, self.flavor_type)) self.assertIsInstance(f, self.flavor_type)
self.assertEqual(f.ram, 256) self.assertEqual(f.ram, 256)
self.assertEqual(f.disk, 10) self.assertEqual(f.disk, 10)
self.assertEqual(f.ephemeral, 10) self.assertEqual(f.ephemeral, 10)
@ -73,7 +73,7 @@ class FlavorsTest(utils.TestCase):
def test_get_flavor_details_alphanum_id(self): def test_get_flavor_details_alphanum_id(self):
f = self.cs.flavors.get('aa1') f = self.cs.flavors.get('aa1')
self.cs.assert_called('GET', '/flavors/aa1') self.cs.assert_called('GET', '/flavors/aa1')
self.assertTrue(isinstance(f, self.flavor_type)) self.assertIsInstance(f, self.flavor_type)
self.assertEqual(f.ram, 128) self.assertEqual(f.ram, 128)
self.assertEqual(f.disk, 0) self.assertEqual(f.disk, 0)
self.assertEqual(f.ephemeral, 0) self.assertEqual(f.ephemeral, 0)
@ -82,7 +82,7 @@ class FlavorsTest(utils.TestCase):
def test_get_flavor_details_diablo(self): def test_get_flavor_details_diablo(self):
f = self.cs.flavors.get(3) f = self.cs.flavors.get(3)
self.cs.assert_called('GET', '/flavors/3') self.cs.assert_called('GET', '/flavors/3')
self.assertTrue(isinstance(f, self.flavor_type)) self.assertIsInstance(f, self.flavor_type)
self.assertEqual(f.ram, 256) self.assertEqual(f.ram, 256)
self.assertEqual(f.disk, 10) self.assertEqual(f.disk, 10)
self.assertEqual(f.ephemeral, 'N/A') self.assertEqual(f.ephemeral, 'N/A')
@ -123,7 +123,7 @@ class FlavorsTest(utils.TestCase):
False) False)
self.cs.assert_called('POST', '/flavors', body) self.cs.assert_called('POST', '/flavors', body)
self.assertTrue(isinstance(f, self.flavor_type)) self.assertIsInstance(f, self.flavor_type)
def test_create_with_id_as_string(self): def test_create_with_id_as_string(self):
flavor_id = 'foobar' flavor_id = 'foobar'
@ -135,7 +135,7 @@ class FlavorsTest(utils.TestCase):
1.0, False) 1.0, False)
self.cs.assert_called('POST', '/flavors', body) self.cs.assert_called('POST', '/flavors', body)
self.assertTrue(isinstance(f, self.flavor_type)) self.assertIsInstance(f, self.flavor_type)
def test_create_ephemeral_ispublic_defaults(self): def test_create_ephemeral_ispublic_defaults(self):
f = self.cs.flavors.create("flavorcreate", 512, 1, 10, 1234) f = self.cs.flavors.create("flavorcreate", 512, 1, 10, 1234)
@ -144,7 +144,7 @@ class FlavorsTest(utils.TestCase):
1.0, True) 1.0, True)
self.cs.assert_called('POST', '/flavors', body) self.cs.assert_called('POST', '/flavors', body)
self.assertTrue(isinstance(f, self.flavor_type)) self.assertIsInstance(f, self.flavor_type)
def test_invalid_parameters_create(self): def test_invalid_parameters_create(self):
self.assertRaises(exceptions.CommandError, self.cs.flavors.create, self.assertRaises(exceptions.CommandError, self.cs.flavors.create,

View File

@ -28,8 +28,8 @@ class FloatingIPDNSDomainTest(utils.TestCase):
self.assertEqual(len(domainlist), 2) self.assertEqual(len(domainlist), 2)
for entry in domainlist: for entry in domainlist:
self.assertTrue(isinstance(entry, self.assertIsInstance(entry,
floating_ip_dns.FloatingIPDNSDomain)) floating_ip_dns.FloatingIPDNSDomain)
self.assertEqual(domainlist[1].domain, 'example.com') self.assertEqual(domainlist[1].domain, 'example.com')
@ -61,8 +61,8 @@ class FloatingIPDNSEntryTest(utils.TestCase):
self.assertEqual(len(entries), 2) self.assertEqual(len(entries), 2)
for entry in entries: for entry in entries:
self.assertTrue(isinstance(entry, self.assertIsInstance(entry,
floating_ip_dns.FloatingIPDNSEntry)) floating_ip_dns.FloatingIPDNSEntry)
self.assertEqual(entries[1].dns_entry['name'], 'host2') self.assertEqual(entries[1].dns_entry['name'], 'host2')
self.assertEqual(entries[1].dns_entry['ip'], self.testip) self.assertEqual(entries[1].dns_entry['ip'], self.testip)
@ -70,7 +70,7 @@ class FloatingIPDNSEntryTest(utils.TestCase):
def test_get_dns_entry_by_name(self): def test_get_dns_entry_by_name(self):
entry = cs.dns_entries.get(self.testdomain, entry = cs.dns_entries.get(self.testdomain,
self.testname) self.testname)
self.assertTrue(isinstance(entry, floating_ip_dns.FloatingIPDNSEntry)) self.assertIsInstance(entry, floating_ip_dns.FloatingIPDNSEntry)
self.assertEqual(entry.name, self.testname) self.assertEqual(entry.name, self.testname)
def test_create_entry(self): def test_create_entry(self):

View File

@ -27,5 +27,5 @@ class TestFloatingIPPools(utils.TestCase):
def test_list_floating_ips(self): def test_list_floating_ips(self):
fl = cs.floating_ip_pools.list() fl = cs.floating_ip_pools.list()
cs.assert_called('GET', '/os-floating-ip-pools') cs.assert_called('GET', '/os-floating-ip-pools')
[self.assertTrue(isinstance(f, floating_ip_pools.FloatingIPPool)) [self.assertIsInstance(f, floating_ip_pools.FloatingIPPool)
for f in fl] for f in fl]

View File

@ -27,7 +27,7 @@ class FloatingIPsTest(utils.TestCase):
def test_list_floating_ips(self): def test_list_floating_ips(self):
fl = cs.floating_ips.list() fl = cs.floating_ips.list()
cs.assert_called('GET', '/os-floating-ips') cs.assert_called('GET', '/os-floating-ips')
[self.assertTrue(isinstance(f, floating_ips.FloatingIP)) for f in fl] [self.assertIsInstance(f, floating_ips.FloatingIP) for f in fl]
def test_delete_floating_ip(self): def test_delete_floating_ip(self):
fl = cs.floating_ips.list()[0] fl = cs.floating_ips.list()[0]
@ -42,10 +42,10 @@ class FloatingIPsTest(utils.TestCase):
fl = cs.floating_ips.create() fl = cs.floating_ips.create()
cs.assert_called('POST', '/os-floating-ips') cs.assert_called('POST', '/os-floating-ips')
self.assertEqual(fl.pool, None) self.assertEqual(fl.pool, None)
self.assertTrue(isinstance(fl, floating_ips.FloatingIP)) self.assertIsInstance(fl, floating_ips.FloatingIP)
def test_create_floating_ip_with_pool(self): def test_create_floating_ip_with_pool(self):
fl = cs.floating_ips.create('foo') fl = cs.floating_ips.create('foo')
cs.assert_called('POST', '/os-floating-ips') cs.assert_called('POST', '/os-floating-ips')
self.assertEqual(fl.pool, 'nova') self.assertEqual(fl.pool, 'nova')
self.assertTrue(isinstance(fl, floating_ips.FloatingIP)) self.assertIsInstance(fl, floating_ips.FloatingIP)

View File

@ -26,13 +26,13 @@ class FloatingIPsBulkTest(utils.TestCase):
def test_list_floating_ips_bulk(self): def test_list_floating_ips_bulk(self):
fl = cs.floating_ips_bulk.list() fl = cs.floating_ips_bulk.list()
cs.assert_called('GET', '/os-floating-ips-bulk') cs.assert_called('GET', '/os-floating-ips-bulk')
[self.assertTrue(isinstance(f, floating_ips_bulk.FloatingIP)) [self.assertIsInstance(f, floating_ips_bulk.FloatingIP)
for f in fl] for f in fl]
def test_list_floating_ips_bulk_host_filter(self): def test_list_floating_ips_bulk_host_filter(self):
fl = cs.floating_ips_bulk.list('testHost') fl = cs.floating_ips_bulk.list('testHost')
cs.assert_called('GET', '/os-floating-ips-bulk/testHost') cs.assert_called('GET', '/os-floating-ips-bulk/testHost')
[self.assertTrue(isinstance(f, floating_ips_bulk.FloatingIP)) [self.assertIsInstance(f, floating_ips_bulk.FloatingIP)
for f in fl] for f in fl]
def test_create_floating_ips_bulk(self): def test_create_floating_ips_bulk(self):

View File

@ -31,31 +31,31 @@ class FpingTest(utils.TestCase):
fl = cs.fping.list() fl = cs.fping.list()
cs.assert_called('GET', '/os-fping') cs.assert_called('GET', '/os-fping')
for f in fl: for f in fl:
self.assertTrue(isinstance(f, fping.Fping)) self.assertIsInstance(f, fping.Fping)
self.assertEqual(f.project_id, "fake-project") self.assertEqual(f.project_id, "fake-project")
self.assertEqual(f.alive, True) self.assertEqual(f.alive, True)
def test_list_fpings_all_tenants(self): def test_list_fpings_all_tenants(self):
fl = cs.fping.list(all_tenants=True) fl = cs.fping.list(all_tenants=True)
for f in fl: for f in fl:
self.assertTrue(isinstance(f, fping.Fping)) self.assertIsInstance(f, fping.Fping)
cs.assert_called('GET', '/os-fping?all_tenants=1') cs.assert_called('GET', '/os-fping?all_tenants=1')
def test_list_fpings_exclude(self): def test_list_fpings_exclude(self):
fl = cs.fping.list(exclude=['1']) fl = cs.fping.list(exclude=['1'])
for f in fl: for f in fl:
self.assertTrue(isinstance(f, fping.Fping)) self.assertIsInstance(f, fping.Fping)
cs.assert_called('GET', '/os-fping?exclude=1') cs.assert_called('GET', '/os-fping?exclude=1')
def test_list_fpings_include(self): def test_list_fpings_include(self):
fl = cs.fping.list(include=['1']) fl = cs.fping.list(include=['1'])
for f in fl: for f in fl:
self.assertTrue(isinstance(f, fping.Fping)) self.assertIsInstance(f, fping.Fping)
cs.assert_called('GET', '/os-fping?include=1') cs.assert_called('GET', '/os-fping?include=1')
def test_get_fping(self): def test_get_fping(self):
f = cs.fping.get(1) f = cs.fping.get(1)
cs.assert_called('GET', '/os-fping/1') cs.assert_called('GET', '/os-fping/1')
self.assertTrue(isinstance(f, fping.Fping)) self.assertIsInstance(f, fping.Fping)
self.assertEqual(f.project_id, "fake-project") self.assertEqual(f.project_id, "fake-project")
self.assertEqual(f.alive, True) self.assertEqual(f.alive, True)

View File

@ -24,18 +24,18 @@ class HostsTest(utils.TestCase):
def test_describe_resource(self): def test_describe_resource(self):
hs = cs.hosts.get('host') hs = cs.hosts.get('host')
cs.assert_called('GET', '/os-hosts/host') cs.assert_called('GET', '/os-hosts/host')
[self.assertTrue(isinstance(h, hosts.Host)) for h in hs] [self.assertIsInstance(h, hosts.Host) for h in hs]
def test_list_host(self): def test_list_host(self):
hs = cs.hosts.list() hs = cs.hosts.list()
cs.assert_called('GET', '/os-hosts') cs.assert_called('GET', '/os-hosts')
[self.assertTrue(isinstance(h, hosts.Host)) for h in hs] [self.assertIsInstance(h, hosts.Host) for h in hs]
[self.assertEqual(h.zone, 'nova1') for h in hs] [self.assertEqual(h.zone, 'nova1') for h in hs]
def test_list_host_with_zone(self): def test_list_host_with_zone(self):
hs = cs.hosts.list('nova') hs = cs.hosts.list('nova')
cs.assert_called('GET', '/os-hosts?zone=nova') cs.assert_called('GET', '/os-hosts?zone=nova')
[self.assertTrue(isinstance(h, hosts.Host)) for h in hs] [self.assertIsInstance(h, hosts.Host) for h in hs]
[self.assertEqual(h.zone, 'nova') for h in hs] [self.assertEqual(h.zone, 'nova') for h in hs]
def test_update_enable(self): def test_update_enable(self):
@ -43,14 +43,14 @@ class HostsTest(utils.TestCase):
values = {"status": "enabled"} values = {"status": "enabled"}
result = host.update(values) result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', values) cs.assert_called('PUT', '/os-hosts/sample_host', values)
self.assertTrue(isinstance(result, hosts.Host)) self.assertIsInstance(result, hosts.Host)
def test_update_maintenance(self): def test_update_maintenance(self):
host = cs.hosts.get('sample_host')[0] host = cs.hosts.get('sample_host')[0]
values = {"maintenance_mode": "enable"} values = {"maintenance_mode": "enable"}
result = host.update(values) result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', values) cs.assert_called('PUT', '/os-hosts/sample_host', values)
self.assertTrue(isinstance(result, hosts.Host)) self.assertIsInstance(result, hosts.Host)
def test_update_both(self): def test_update_both(self):
host = cs.hosts.get('sample_host')[0] host = cs.hosts.get('sample_host')[0]
@ -58,7 +58,7 @@ class HostsTest(utils.TestCase):
"maintenance_mode": "enable"} "maintenance_mode": "enable"}
result = host.update(values) result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', values) cs.assert_called('PUT', '/os-hosts/sample_host', values)
self.assertTrue(isinstance(result, hosts.Host)) self.assertIsInstance(result, hosts.Host)
def test_host_startup(self): def test_host_startup(self):
host = cs.hosts.get('sample_host')[0] host = cs.hosts.get('sample_host')[0]

View File

@ -24,12 +24,12 @@ class ImagesTest(utils.TestCase):
def test_list_images(self): def test_list_images(self):
il = cs.images.list() il = cs.images.list()
cs.assert_called('GET', '/images/detail') cs.assert_called('GET', '/images/detail')
[self.assertTrue(isinstance(i, images.Image)) for i in il] [self.assertIsInstance(i, images.Image) for i in il]
def test_list_images_undetailed(self): def test_list_images_undetailed(self):
il = cs.images.list(detailed=False) il = cs.images.list(detailed=False)
cs.assert_called('GET', '/images') cs.assert_called('GET', '/images')
[self.assertTrue(isinstance(i, images.Image)) for i in il] [self.assertIsInstance(i, images.Image) for i in il]
def test_list_images_with_limit(self): def test_list_images_with_limit(self):
il = cs.images.list(limit=4) il = cs.images.list(limit=4)
@ -38,7 +38,7 @@ class ImagesTest(utils.TestCase):
def test_get_image_details(self): def test_get_image_details(self):
i = cs.images.get(1) i = cs.images.get(1)
cs.assert_called('GET', '/images/1') cs.assert_called('GET', '/images/1')
self.assertTrue(isinstance(i, images.Image)) self.assertIsInstance(i, images.Image)
self.assertEqual(i.id, 1) self.assertEqual(i.id, 1)
self.assertEqual(i.name, 'CentOS 5.2') self.assertEqual(i.name, 'CentOS 5.2')

View File

@ -32,13 +32,13 @@ class KeypairsTest(utils.TestCase):
def test_get_keypair(self): def test_get_keypair(self):
kp = self.cs.keypairs.get('test') kp = self.cs.keypairs.get('test')
self.cs.assert_called('GET', '/%s/test' % self.keypair_prefix) self.cs.assert_called('GET', '/%s/test' % self.keypair_prefix)
self.assertTrue(isinstance(kp, keypairs.Keypair)) self.assertIsInstance(kp, keypairs.Keypair)
self.assertEqual(kp.name, 'test') self.assertEqual(kp.name, 'test')
def test_list_keypairs(self): def test_list_keypairs(self):
kps = self.cs.keypairs.list() kps = self.cs.keypairs.list()
self.cs.assert_called('GET', '/%s' % self.keypair_prefix) self.cs.assert_called('GET', '/%s' % self.keypair_prefix)
[self.assertTrue(isinstance(kp, keypairs.Keypair)) for kp in kps] [self.assertIsInstance(kp, keypairs.Keypair) for kp in kps]
def test_delete_keypair(self): def test_delete_keypair(self):
kp = self.cs.keypairs.list()[0] kp = self.cs.keypairs.list()[0]
@ -52,9 +52,9 @@ class KeypairsTest(utils.TestCase):
def test_create_keypair(self): def test_create_keypair(self):
kp = self.cs.keypairs.create("foo") kp = self.cs.keypairs.create("foo")
self.cs.assert_called('POST', '/%s' % self.keypair_prefix) self.cs.assert_called('POST', '/%s' % self.keypair_prefix)
self.assertTrue(isinstance(kp, keypairs.Keypair)) self.assertIsInstance(kp, keypairs.Keypair)
def test_import_keypair(self): def test_import_keypair(self):
kp = self.cs.keypairs.create("foo", "fake-public-key") kp = self.cs.keypairs.create("foo", "fake-public-key")
self.cs.assert_called('POST', '/%s' % self.keypair_prefix) self.cs.assert_called('POST', '/%s' % self.keypair_prefix)
self.assertTrue(isinstance(kp, keypairs.Keypair)) self.assertIsInstance(kp, keypairs.Keypair)

View File

@ -24,12 +24,12 @@ class LimitsTest(utils.TestCase):
def test_get_limits(self): def test_get_limits(self):
obj = cs.limits.get() obj = cs.limits.get()
cs.assert_called('GET', '/limits') cs.assert_called('GET', '/limits')
self.assertTrue(isinstance(obj, limits.Limits)) self.assertIsInstance(obj, limits.Limits)
def test_get_limits_for_a_tenant(self): def test_get_limits_for_a_tenant(self):
obj = cs.limits.get(tenant_id=1234) obj = cs.limits.get(tenant_id=1234)
cs.assert_called('GET', '/limits?tenant_id=1234') cs.assert_called('GET', '/limits?tenant_id=1234')
self.assertTrue(isinstance(obj, limits.Limits)) self.assertIsInstance(obj, limits.Limits)
def test_absolute_limits(self): def test_absolute_limits(self):
obj = cs.limits.get() obj = cs.limits.get()

View File

@ -24,12 +24,12 @@ class NetworksTest(utils.TestCase):
def test_list_networks(self): def test_list_networks(self):
fl = cs.networks.list() fl = cs.networks.list()
cs.assert_called('GET', '/os-networks') cs.assert_called('GET', '/os-networks')
[self.assertTrue(isinstance(f, networks.Network)) for f in fl] [self.assertIsInstance(f, networks.Network) for f in fl]
def test_get_network(self): def test_get_network(self):
f = cs.networks.get(1) f = cs.networks.get(1)
cs.assert_called('GET', '/os-networks/1') cs.assert_called('GET', '/os-networks/1')
self.assertTrue(isinstance(f, networks.Network)) self.assertIsInstance(f, networks.Network)
def test_delete(self): def test_delete(self):
cs.networks.delete('networkdelete') cs.networks.delete('networkdelete')
@ -39,7 +39,7 @@ class NetworksTest(utils.TestCase):
f = cs.networks.create(label='foo') f = cs.networks.create(label='foo')
cs.assert_called('POST', '/os-networks', cs.assert_called('POST', '/os-networks',
{'network': {'label': 'foo'}}) {'network': {'label': 'foo'}})
self.assertTrue(isinstance(f, networks.Network)) self.assertIsInstance(f, networks.Network)
def test_create_allparams(self): def test_create_allparams(self):
params = { params = {
@ -62,7 +62,7 @@ class NetworksTest(utils.TestCase):
f = cs.networks.create(**params) f = cs.networks.create(**params)
cs.assert_called('POST', '/os-networks', {'network': params}) cs.assert_called('POST', '/os-networks', {'network': params})
self.assertTrue(isinstance(f, networks.Network)) self.assertIsInstance(f, networks.Network)
def test_associate_project(self): def test_associate_project(self):
cs.networks.associate_project('networktest') cs.networks.associate_project('networktest')

View File

@ -24,7 +24,7 @@ class SecurityGroupsTest(utils.TestCase):
sgs = cs.security_groups.list(search_opts=search_opts) sgs = cs.security_groups.list(search_opts=search_opts)
cs.assert_called('GET', path) cs.assert_called('GET', path)
for sg in sgs: for sg in sgs:
self.assertTrue(isinstance(sg, security_groups.SecurityGroup)) self.assertIsInstance(sg, security_groups.SecurityGroup)
def test_list_security_groups_all_tenants_on(self): def test_list_security_groups_all_tenants_on(self):
self._do_test_list_security_groups( self._do_test_list_security_groups(
@ -41,7 +41,7 @@ class SecurityGroupsTest(utils.TestCase):
def test_get_security_groups(self): def test_get_security_groups(self):
sg = cs.security_groups.get(1) sg = cs.security_groups.get(1)
cs.assert_called('GET', '/os-security-groups/1') cs.assert_called('GET', '/os-security-groups/1')
self.assertTrue(isinstance(sg, security_groups.SecurityGroup)) self.assertIsInstance(sg, security_groups.SecurityGroup)
self.assertEqual('1', str(sg)) self.assertEqual('1', str(sg))
def test_delete_security_group(self): def test_delete_security_group(self):
@ -56,13 +56,13 @@ class SecurityGroupsTest(utils.TestCase):
def test_create_security_group(self): def test_create_security_group(self):
sg = cs.security_groups.create("foo", "foo barr") sg = cs.security_groups.create("foo", "foo barr")
cs.assert_called('POST', '/os-security-groups') cs.assert_called('POST', '/os-security-groups')
self.assertTrue(isinstance(sg, security_groups.SecurityGroup)) self.assertIsInstance(sg, security_groups.SecurityGroup)
def test_update_security_group(self): def test_update_security_group(self):
sg = cs.security_groups.list()[0] sg = cs.security_groups.list()[0]
secgroup = cs.security_groups.update(sg, "update", "update") secgroup = cs.security_groups.update(sg, "update", "update")
cs.assert_called('PUT', '/os-security-groups/1') cs.assert_called('PUT', '/os-security-groups/1')
self.assertTrue(isinstance(secgroup, security_groups.SecurityGroup)) self.assertIsInstance(secgroup, security_groups.SecurityGroup)
def test_refresh_security_group(self): def test_refresh_security_group(self):
sg = cs.security_groups.get(1) sg = cs.security_groups.get(1)

View File

@ -29,23 +29,23 @@ class ServersTest(utils.TestCase):
def test_list_servers(self): def test_list_servers(self):
sl = cs.servers.list() sl = cs.servers.list()
cs.assert_called('GET', '/servers/detail') cs.assert_called('GET', '/servers/detail')
[self.assertTrue(isinstance(s, servers.Server)) for s in sl] [self.assertIsInstance(s, servers.Server) for s in sl]
def test_list_servers_undetailed(self): def test_list_servers_undetailed(self):
sl = cs.servers.list(detailed=False) sl = cs.servers.list(detailed=False)
cs.assert_called('GET', '/servers') cs.assert_called('GET', '/servers')
[self.assertTrue(isinstance(s, servers.Server)) for s in sl] [self.assertIsInstance(s, servers.Server) for s in sl]
def test_list_servers_with_marker_limit(self): def test_list_servers_with_marker_limit(self):
sl = cs.servers.list(marker=1234, limit=2) sl = cs.servers.list(marker=1234, limit=2)
cs.assert_called('GET', '/servers/detail?limit=2&marker=1234') cs.assert_called('GET', '/servers/detail?limit=2&marker=1234')
for s in sl: for s in sl:
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_get_server_details(self): def test_get_server_details(self):
s = cs.servers.get(1234) s = cs.servers.get(1234)
cs.assert_called('GET', '/servers/1234') cs.assert_called('GET', '/servers/1234')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
self.assertEqual(s.id, 1234) self.assertEqual(s.id, 1234)
self.assertEqual(s.status, 'BUILD') self.assertEqual(s.status, 'BUILD')
@ -70,7 +70,7 @@ class ServersTest(utils.TestCase):
} }
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_create_server_boot_from_volume_with_nics(self): def test_create_server_boot_from_volume_with_nics(self):
old_boot = cs.servers._boot old_boot = cs.servers._boot
@ -100,7 +100,7 @@ class ServersTest(utils.TestCase):
nics=nics nics=nics
) )
cs.assert_called('POST', '/os-volumes_boot') cs.assert_called('POST', '/os-volumes_boot')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
test_create_server_from_volume() test_create_server_from_volume()
@ -117,7 +117,7 @@ class ServersTest(utils.TestCase):
}, },
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_create_server_userdata_unicode(self): def test_create_server_userdata_unicode(self):
s = cs.servers.create( s = cs.servers.create(
@ -133,7 +133,7 @@ class ServersTest(utils.TestCase):
}, },
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_create_server_userdata_utf8(self): def test_create_server_userdata_utf8(self):
s = cs.servers.create( s = cs.servers.create(
@ -149,7 +149,7 @@ class ServersTest(utils.TestCase):
}, },
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def _create_disk_config(self, disk_config): def _create_disk_config(self, disk_config):
s = cs.servers.create( s = cs.servers.create(
@ -159,7 +159,7 @@ class ServersTest(utils.TestCase):
disk_config=disk_config disk_config=disk_config
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
# verify disk config param was used in the request: # verify disk config param was used in the request:
last_request = cs.client.callstack[-1] last_request = cs.client.callstack[-1]

View File

@ -34,7 +34,7 @@ class ServicesTest(utils.TestCase):
svs = self.cs.services.list() svs = self.cs.services.list()
self.cs.assert_called('GET', '/os-services') self.cs.assert_called('GET', '/os-services')
for s in svs: for s in svs:
self.assertTrue(isinstance(s, self._get_service_type())) self.assertIsInstance(s, self._get_service_type())
self.assertEqual(s.binary, 'nova-compute') self.assertEqual(s.binary, 'nova-compute')
self.assertEqual(s.host, 'host1') self.assertEqual(s.host, 'host1')
@ -42,7 +42,7 @@ class ServicesTest(utils.TestCase):
svs = self.cs.services.list(host='host2') svs = self.cs.services.list(host='host2')
self.cs.assert_called('GET', '/os-services?host=host2') self.cs.assert_called('GET', '/os-services?host=host2')
for s in svs: for s in svs:
self.assertTrue(isinstance(s, self._get_service_type())) self.assertIsInstance(s, self._get_service_type())
self.assertEqual(s.binary, 'nova-compute') self.assertEqual(s.binary, 'nova-compute')
self.assertEqual(s.host, 'host2') self.assertEqual(s.host, 'host2')
@ -50,7 +50,7 @@ class ServicesTest(utils.TestCase):
svs = self.cs.services.list(binary='nova-cert') svs = self.cs.services.list(binary='nova-cert')
self.cs.assert_called('GET', '/os-services?binary=nova-cert') self.cs.assert_called('GET', '/os-services?binary=nova-cert')
for s in svs: for s in svs:
self.assertTrue(isinstance(s, self._get_service_type())) self.assertIsInstance(s, self._get_service_type())
self.assertEqual(s.binary, 'nova-cert') self.assertEqual(s.binary, 'nova-cert')
self.assertEqual(s.host, 'host1') self.assertEqual(s.host, 'host1')
@ -59,7 +59,7 @@ class ServicesTest(utils.TestCase):
self.cs.assert_called('GET', self.cs.assert_called('GET',
'/os-services?host=host2&binary=nova-cert') '/os-services?host=host2&binary=nova-cert')
for s in svs: for s in svs:
self.assertTrue(isinstance(s, self._get_service_type())) self.assertIsInstance(s, self._get_service_type())
self.assertEqual(s.binary, 'nova-cert') self.assertEqual(s.binary, 'nova-cert')
self.assertEqual(s.host, 'host2') self.assertEqual(s.host, 'host2')
@ -74,14 +74,14 @@ class ServicesTest(utils.TestCase):
service = self.cs.services.enable('host1', 'nova-cert') service = self.cs.services.enable('host1', 'nova-cert')
values = self._update_body("host1", "nova-cert") values = self._update_body("host1", "nova-cert")
self.cs.assert_called('PUT', '/os-services/enable', values) self.cs.assert_called('PUT', '/os-services/enable', values)
self.assertTrue(isinstance(service, self._get_service_type())) self.assertIsInstance(service, self._get_service_type())
self.assertEqual(service.status, 'enabled') self.assertEqual(service.status, 'enabled')
def test_services_disable(self): def test_services_disable(self):
service = self.cs.services.disable('host1', 'nova-cert') service = self.cs.services.disable('host1', 'nova-cert')
values = self._update_body("host1", "nova-cert") values = self._update_body("host1", "nova-cert")
self.cs.assert_called('PUT', '/os-services/disable', values) self.cs.assert_called('PUT', '/os-services/disable', values)
self.assertTrue(isinstance(service, self._get_service_type())) self.assertIsInstance(service, self._get_service_type())
self.assertEqual(service.status, 'disabled') self.assertEqual(service.status, 'disabled')
def test_services_disable_log_reason(self): def test_services_disable_log_reason(self):
@ -90,5 +90,5 @@ class ServicesTest(utils.TestCase):
values = self._update_body("compute1", "nova-compute", values = self._update_body("compute1", "nova-compute",
"disable bad host") "disable bad host")
self.cs.assert_called('PUT', '/os-services/disable-log-reason', values) self.cs.assert_called('PUT', '/os-services/disable-log-reason', values)
self.assertTrue(isinstance(service, self._get_service_type())) self.assertIsInstance(service, self._get_service_type())
self.assertEqual(service.status, 'disabled') self.assertEqual(service.status, 'disabled')

View File

@ -39,7 +39,7 @@ class UsageTest(utils.TestCase):
("start=%s&" % now.isoformat()) + ("start=%s&" % now.isoformat()) +
("end=%s&" % now.isoformat()) + ("end=%s&" % now.isoformat()) +
("detailed=%s" % int(bool(detailed)))) ("detailed=%s" % int(bool(detailed))))
[self.assertTrue(isinstance(u, usage.Usage)) for u in usages] [self.assertIsInstance(u, usage.Usage) for u in usages]
def test_usage_list_detailed(self): def test_usage_list_detailed(self):
self.test_usage_list(True) self.test_usage_list(True)
@ -52,4 +52,4 @@ class UsageTest(utils.TestCase):
"/os-simple-tenant-usage/tenantfoo?" + "/os-simple-tenant-usage/tenantfoo?" +
("start=%s&" % now.isoformat()) + ("start=%s&" % now.isoformat()) +
("end=%s" % now.isoformat())) ("end=%s" % now.isoformat()))
self.assertTrue(isinstance(u, usage.Usage)) self.assertIsInstance(u, usage.Usage)

View File

@ -26,18 +26,18 @@ class VolumesTest(utils.TestCase):
def test_list_servers(self): def test_list_servers(self):
vl = cs.volumes.list() vl = cs.volumes.list()
cs.assert_called('GET', '/volumes/detail') cs.assert_called('GET', '/volumes/detail')
[self.assertTrue(isinstance(v, volumes.Volume)) for v in vl] [self.assertIsInstance(v, volumes.Volume) for v in vl]
def test_list_volumes_undetailed(self): def test_list_volumes_undetailed(self):
vl = cs.volumes.list(detailed=False) vl = cs.volumes.list(detailed=False)
cs.assert_called('GET', '/volumes') cs.assert_called('GET', '/volumes')
[self.assertTrue(isinstance(v, volumes.Volume)) for v in vl] [self.assertIsInstance(v, volumes.Volume) for v in vl]
def test_get_volume_details(self): def test_get_volume_details(self):
vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983' vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983'
v = cs.volumes.get(vol_id) v = cs.volumes.get(vol_id)
cs.assert_called('GET', '/volumes/%s' % vol_id) cs.assert_called('GET', '/volumes/%s' % vol_id)
self.assertTrue(isinstance(v, volumes.Volume)) self.assertIsInstance(v, volumes.Volume)
self.assertEqual(v.id, vol_id) self.assertEqual(v.id, vol_id)
def test_create_volume(self): def test_create_volume(self):
@ -47,7 +47,7 @@ class VolumesTest(utils.TestCase):
display_description="My volume desc", display_description="My volume desc",
) )
cs.assert_called('POST', '/volumes') cs.assert_called('POST', '/volumes')
self.assertTrue(isinstance(v, volumes.Volume)) self.assertIsInstance(v, volumes.Volume)
def test_delete_volume(self): def test_delete_volume(self):
vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983' vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983'
@ -66,7 +66,7 @@ class VolumesTest(utils.TestCase):
device='/dev/vdb' device='/dev/vdb'
) )
cs.assert_called('POST', '/servers/1234/os-volume_attachments') cs.assert_called('POST', '/servers/1234/os-volume_attachments')
self.assertTrue(isinstance(v, volumes.Volume)) self.assertIsInstance(v, volumes.Volume)
def test_update_server_volume(self): def test_update_server_volume(self):
vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983' vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983'
@ -76,17 +76,17 @@ class VolumesTest(utils.TestCase):
new_volume_id=vol_id new_volume_id=vol_id
) )
cs.assert_called('PUT', '/servers/1234/os-volume_attachments/Work') cs.assert_called('PUT', '/servers/1234/os-volume_attachments/Work')
self.assertTrue(isinstance(v, volumes.Volume)) self.assertIsInstance(v, volumes.Volume)
def test_get_server_volume(self): def test_get_server_volume(self):
v = cs.volumes.get_server_volume(1234, 'Work') v = cs.volumes.get_server_volume(1234, 'Work')
cs.assert_called('GET', '/servers/1234/os-volume_attachments/Work') cs.assert_called('GET', '/servers/1234/os-volume_attachments/Work')
self.assertTrue(isinstance(v, volumes.Volume)) self.assertIsInstance(v, volumes.Volume)
def test_list_server_volumes(self): def test_list_server_volumes(self):
vl = cs.volumes.get_server_volumes(1234) vl = cs.volumes.get_server_volumes(1234)
cs.assert_called('GET', '/servers/1234/os-volume_attachments') cs.assert_called('GET', '/servers/1234/os-volume_attachments')
[self.assertTrue(isinstance(v, volumes.Volume)) for v in vl] [self.assertIsInstance(v, volumes.Volume) for v in vl]
def test_delete_server_volume(self): def test_delete_server_volume(self):
cs.volumes.delete_server_volume(1234, 'Work') cs.volumes.delete_server_volume(1234, 'Work')

View File

@ -29,8 +29,8 @@ class FlavorAccessTest(utils.TestCase):
r = cs.flavor_access.list(**kwargs) r = cs.flavor_access.list(**kwargs)
cs.assert_called('GET', '/flavors/2/flavor-access') cs.assert_called('GET', '/flavors/2/flavor-access')
for access_list in r: for access_list in r:
self.assertTrue(isinstance(access_list, self.assertIsInstance(access_list,
flavor_access.FlavorAccess)) flavor_access.FlavorAccess)
def test_add_tenant_access(self): def test_add_tenant_access(self):
flavor = cs.flavors.get(2) flavor = cs.flavors.get(2)
@ -45,7 +45,7 @@ class FlavorAccessTest(utils.TestCase):
cs.assert_called('POST', '/flavors/2/action', body) cs.assert_called('POST', '/flavors/2/action', body)
for a in r: for a in r:
self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) self.assertIsInstance(a, flavor_access.FlavorAccess)
def test_remove_tenant_access(self): def test_remove_tenant_access(self):
flavor = cs.flavors.get(2) flavor = cs.flavors.get(2)
@ -60,4 +60,4 @@ class FlavorAccessTest(utils.TestCase):
cs.assert_called('POST', '/flavors/2/action', body) cs.assert_called('POST', '/flavors/2/action', body)
for a in r: for a in r:
self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) self.assertIsInstance(a, flavor_access.FlavorAccess)

View File

@ -26,20 +26,20 @@ class HostsTest(utils.TestCase):
hs = cs.hosts.get('host') hs = cs.hosts.get('host')
cs.assert_called('GET', '/os-hosts/host') cs.assert_called('GET', '/os-hosts/host')
for h in hs: for h in hs:
self.assertTrue(isinstance(h, hosts.Host)) self.assertIsInstance(h, hosts.Host)
def test_list_host(self): def test_list_host(self):
hs = cs.hosts.list() hs = cs.hosts.list()
cs.assert_called('GET', '/os-hosts') cs.assert_called('GET', '/os-hosts')
for h in hs: for h in hs:
self.assertTrue(isinstance(h, hosts.Host)) self.assertIsInstance(h, hosts.Host)
self.assertEqual(h.zone, 'nova1') self.assertEqual(h.zone, 'nova1')
def test_list_host_with_zone(self): def test_list_host_with_zone(self):
hs = cs.hosts.list('nova') hs = cs.hosts.list('nova')
cs.assert_called('GET', '/os-hosts?zone=nova') cs.assert_called('GET', '/os-hosts?zone=nova')
for h in hs: for h in hs:
self.assertTrue(isinstance(h, hosts.Host)) self.assertIsInstance(h, hosts.Host)
self.assertEqual(h.zone, 'nova') self.assertEqual(h.zone, 'nova')
def test_update_enable(self): def test_update_enable(self):
@ -47,14 +47,14 @@ class HostsTest(utils.TestCase):
values = {"status": "enabled"} values = {"status": "enabled"}
result = host.update(values) result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', {"host": values}) cs.assert_called('PUT', '/os-hosts/sample_host', {"host": values})
self.assertTrue(isinstance(result, hosts.Host)) self.assertIsInstance(result, hosts.Host)
def test_update_maintenance(self): def test_update_maintenance(self):
host = cs.hosts.get('sample_host')[0] host = cs.hosts.get('sample_host')[0]
values = {"maintenance_mode": "enable"} values = {"maintenance_mode": "enable"}
result = host.update(values) result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', {"host": values}) cs.assert_called('PUT', '/os-hosts/sample_host', {"host": values})
self.assertTrue(isinstance(result, hosts.Host)) self.assertIsInstance(result, hosts.Host)
def test_update_both(self): def test_update_both(self):
host = cs.hosts.get('sample_host')[0] host = cs.hosts.get('sample_host')[0]
@ -62,7 +62,7 @@ class HostsTest(utils.TestCase):
"maintenance_mode": "enable"} "maintenance_mode": "enable"}
result = host.update(values) result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', {"host": values}) cs.assert_called('PUT', '/os-hosts/sample_host', {"host": values})
self.assertTrue(isinstance(result, hosts.Host)) self.assertIsInstance(result, hosts.Host)
def test_host_startup(self): def test_host_startup(self):
host = cs.hosts.get('sample_host')[0] host = cs.hosts.get('sample_host')[0]

View File

@ -27,13 +27,13 @@ class ImagesTest(utils.TestCase):
il = cs.images.list() il = cs.images.list()
cs.assert_called('GET', '/v1/images/detail') cs.assert_called('GET', '/v1/images/detail')
for i in il: for i in il:
self.assertTrue(isinstance(i, images.Image)) self.assertIsInstance(i, images.Image)
def test_list_images_undetailed(self): def test_list_images_undetailed(self):
il = cs.images.list(detailed=False) il = cs.images.list(detailed=False)
cs.assert_called('GET', '/v1/images') cs.assert_called('GET', '/v1/images')
for i in il: for i in il:
self.assertTrue(isinstance(i, images.Image)) self.assertIsInstance(i, images.Image)
def test_list_images_with_limit(self): def test_list_images_with_limit(self):
il = cs.images.list(limit=4) il = cs.images.list(limit=4)
@ -42,7 +42,7 @@ class ImagesTest(utils.TestCase):
def test_get_image_details(self): def test_get_image_details(self):
i = cs.images.get(1) i = cs.images.get(1)
cs.assert_called('HEAD', '/v1/images/1') cs.assert_called('HEAD', '/v1/images/1')
self.assertTrue(isinstance(i, images.Image)) self.assertIsInstance(i, images.Image)
self.assertEqual(i.id, '1') self.assertEqual(i.id, '1')
self.assertEqual(i.name, 'CentOS 5.2') self.assertEqual(i.name, 'CentOS 5.2')

View File

@ -30,24 +30,24 @@ class ServersTest(utils.TestCase):
sl = cs.servers.list() sl = cs.servers.list()
cs.assert_called('GET', '/servers/detail') cs.assert_called('GET', '/servers/detail')
for s in sl: for s in sl:
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_list_servers_undetailed(self): def test_list_servers_undetailed(self):
sl = cs.servers.list(detailed=False) sl = cs.servers.list(detailed=False)
cs.assert_called('GET', '/servers') cs.assert_called('GET', '/servers')
for s in sl: for s in sl:
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_list_servers_with_marker_limit(self): def test_list_servers_with_marker_limit(self):
sl = cs.servers.list(marker=1234, limit=2) sl = cs.servers.list(marker=1234, limit=2)
cs.assert_called('GET', '/servers/detail?limit=2&marker=1234') cs.assert_called('GET', '/servers/detail?limit=2&marker=1234')
for s in sl: for s in sl:
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_get_server_details(self): def test_get_server_details(self):
s = cs.servers.get(1234) s = cs.servers.get(1234)
cs.assert_called('GET', '/servers/1234') cs.assert_called('GET', '/servers/1234')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
self.assertEqual(s.id, 1234) self.assertEqual(s.id, 1234)
self.assertEqual(s.status, 'BUILD') self.assertEqual(s.status, 'BUILD')
@ -72,7 +72,7 @@ class ServersTest(utils.TestCase):
} }
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_create_server_userdata_file_object(self): def test_create_server_userdata_file_object(self):
s = cs.servers.create( s = cs.servers.create(
@ -87,7 +87,7 @@ class ServersTest(utils.TestCase):
}, },
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_create_server_userdata_unicode(self): def test_create_server_userdata_unicode(self):
s = cs.servers.create( s = cs.servers.create(
@ -103,7 +103,7 @@ class ServersTest(utils.TestCase):
}, },
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_create_server_userdata_utf8(self): def test_create_server_userdata_utf8(self):
s = cs.servers.create( s = cs.servers.create(
@ -119,7 +119,7 @@ class ServersTest(utils.TestCase):
}, },
) )
cs.assert_called('POST', '/servers') cs.assert_called('POST', '/servers')
self.assertTrue(isinstance(s, servers.Server)) self.assertIsInstance(s, servers.Server)
def test_update_server(self): def test_update_server(self):
s = cs.servers.get(1234) s = cs.servers.get(1234)