Replace assertEqual(True/False, expr) with assertTrue/assertFalse
In some cases, If the result of expr is a boolen value, we shoud use assertTrue/assertFalse to instead. Because it is clear and simple. Change-Id: I53b345fc3915a7b0e737e9dd4d58fe09c746d61c
This commit is contained in:
parent
b90c780d2b
commit
5bec3b7e3b
@ -112,8 +112,7 @@ class FlavorTests(base.TestCase):
|
|||||||
0,
|
0,
|
||||||
cmd_output["disk"],
|
cmd_output["disk"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(
|
||||||
False,
|
|
||||||
cmd_output["os-flavor-access:is_public"],
|
cmd_output["os-flavor-access:is_public"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -199,8 +198,7 @@ class FlavorTests(base.TestCase):
|
|||||||
20,
|
20,
|
||||||
cmd_output["disk"],
|
cmd_output["disk"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(
|
||||||
False,
|
|
||||||
cmd_output["os-flavor-access:is_public"],
|
cmd_output["os-flavor-access:is_public"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -72,7 +72,7 @@ class ProjectTests(common.IdentityTests):
|
|||||||
self.assert_show_fields(items, fields)
|
self.assert_show_fields(items, fields)
|
||||||
project = self.parse_show_as_object(raw_output)
|
project = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(new_project_name, project['name'])
|
self.assertEqual(new_project_name, project['name'])
|
||||||
self.assertEqual('False', project['enabled'])
|
self.assertFalse(project['enabled'])
|
||||||
self.assertEqual("k0='v0'", project['properties'])
|
self.assertEqual("k0='v0'", project['properties'])
|
||||||
|
|
||||||
def test_project_show(self):
|
def test_project_show(self):
|
||||||
|
@ -42,10 +42,7 @@ class AddressScopeTests(common.NetworkTests):
|
|||||||
cmd_output['name'],
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
# Check the default values
|
# Check the default values
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output['shared'])
|
||||||
False,
|
|
||||||
cmd_output['shared'],
|
|
||||||
)
|
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
@ -80,10 +77,7 @@ class AddressScopeTests(common.NetworkTests):
|
|||||||
4,
|
4,
|
||||||
cmd_output['ip_version'],
|
cmd_output['ip_version'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output['shared'])
|
||||||
True,
|
|
||||||
cmd_output['shared'],
|
|
||||||
)
|
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
@ -101,10 +95,7 @@ class AddressScopeTests(common.NetworkTests):
|
|||||||
6,
|
6,
|
||||||
cmd_output['ip_version'],
|
cmd_output['ip_version'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output['shared'])
|
||||||
False,
|
|
||||||
cmd_output['shared'],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Test list
|
# Test list
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
@ -149,10 +140,7 @@ class AddressScopeTests(common.NetworkTests):
|
|||||||
4,
|
4,
|
||||||
cmd_output['ip_version'],
|
cmd_output['ip_version'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output['shared'])
|
||||||
False,
|
|
||||||
cmd_output['shared'],
|
|
||||||
)
|
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'address scope set ' +
|
'address scope set ' +
|
||||||
@ -174,7 +162,4 @@ class AddressScopeTests(common.NetworkTests):
|
|||||||
4,
|
4,
|
||||||
cmd_output['ip_version'],
|
cmd_output['ip_version'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output['shared'])
|
||||||
True,
|
|
||||||
cmd_output['shared'],
|
|
||||||
)
|
|
||||||
|
@ -70,8 +70,7 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'1.2.4.0/28',
|
'1.2.4.0/28',
|
||||||
cmd_output["cidr"],
|
cmd_output["cidr"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(
|
||||||
True,
|
|
||||||
cmd_output["share_address"],
|
cmd_output["share_address"],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -124,8 +123,7 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'UP',
|
'UP',
|
||||||
cmd_output["admin_state_up"],
|
cmd_output["admin_state_up"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(
|
||||||
False,
|
|
||||||
cmd_output["shared"],
|
cmd_output["shared"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -236,21 +234,14 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'UP',
|
'UP',
|
||||||
cmd_output["admin_state_up"],
|
cmd_output["admin_state_up"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output["shared"])
|
||||||
False,
|
|
||||||
cmd_output["shared"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Internal',
|
'Internal',
|
||||||
cmd_output["router:external"],
|
cmd_output["router:external"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output["is_default"])
|
||||||
False,
|
self.assertTrue(
|
||||||
cmd_output["is_default"],
|
cmd_output["port_security_enabled"]
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
True,
|
|
||||||
cmd_output["port_security_enabled"],
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -278,27 +269,15 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'DOWN',
|
'DOWN',
|
||||||
cmd_output["admin_state_up"],
|
cmd_output["admin_state_up"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output["shared"])
|
||||||
True,
|
self.assertFalse(cmd_output["is_default"])
|
||||||
cmd_output["shared"],
|
self.assertTrue(cmd_output["port_security_enabled"])
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
False,
|
|
||||||
cmd_output["is_default"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
True,
|
|
||||||
cmd_output["port_security_enabled"],
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'4.5.6.0/28',
|
'4.5.6.0/28',
|
||||||
cmd_output["cidr"],
|
cmd_output["cidr"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output["share_address"])
|
||||||
True,
|
|
||||||
cmd_output["share_address"],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Test list
|
# Test list
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
@ -422,22 +401,15 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'UP',
|
'UP',
|
||||||
cmd_output["admin_state_up"],
|
cmd_output["admin_state_up"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output["shared"])
|
||||||
False,
|
|
||||||
cmd_output["shared"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Internal',
|
'Internal',
|
||||||
cmd_output["router:external"],
|
cmd_output["router:external"],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output["is_default"])
|
||||||
False,
|
self.assertTrue(
|
||||||
cmd_output["is_default"],
|
cmd_output["port_security_enabled"]
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
True,
|
|
||||||
cmd_output["port_security_enabled"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -463,19 +435,12 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'DOWN',
|
'DOWN',
|
||||||
cmd_output["admin_state_up"],
|
cmd_output["admin_state_up"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output["shared"])
|
||||||
True,
|
|
||||||
cmd_output["shared"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'External',
|
'External',
|
||||||
cmd_output["router:external"],
|
cmd_output["router:external"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output["is_default"])
|
||||||
False,
|
self.assertFalse(
|
||||||
cmd_output["is_default"],
|
cmd_output["port_security_enabled"]
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
False,
|
|
||||||
cmd_output["port_security_enabled"],
|
|
||||||
)
|
)
|
||||||
|
@ -87,10 +87,7 @@ class NetworkFlavorTests(common.NetworkTests):
|
|||||||
name1,
|
name1,
|
||||||
cmd_output['name'],
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output['enabled'])
|
||||||
True,
|
|
||||||
cmd_output['enabled'],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'testdescription',
|
'testdescription',
|
||||||
cmd_output['description'],
|
cmd_output['description'],
|
||||||
@ -105,10 +102,7 @@ class NetworkFlavorTests(common.NetworkTests):
|
|||||||
name2,
|
name2,
|
||||||
cmd_output['name'],
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(cmd_output['enabled'])
|
||||||
False,
|
|
||||||
cmd_output['enabled'],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'testdescription1',
|
'testdescription1',
|
||||||
cmd_output['description'],
|
cmd_output['description'],
|
||||||
|
@ -35,10 +35,7 @@ class NetworkFlavorProfileTests(common.NetworkTests):
|
|||||||
))
|
))
|
||||||
ID = json_output.get('id')
|
ID = json_output.get('id')
|
||||||
self.assertIsNotNone(ID)
|
self.assertIsNotNone(ID)
|
||||||
self.assertEqual(
|
self.assertTrue(json_output.get('enabled'))
|
||||||
True,
|
|
||||||
json_output.get('enabled'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
@ -61,10 +58,7 @@ class NetworkFlavorProfileTests(common.NetworkTests):
|
|||||||
))
|
))
|
||||||
ID1 = json_output.get('id')
|
ID1 = json_output.get('id')
|
||||||
self.assertIsNotNone(ID1)
|
self.assertIsNotNone(ID1)
|
||||||
self.assertEqual(
|
self.assertTrue(json_output.get('enabled'))
|
||||||
True,
|
|
||||||
json_output.get('enabled'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
@ -82,10 +76,7 @@ class NetworkFlavorProfileTests(common.NetworkTests):
|
|||||||
))
|
))
|
||||||
ID2 = json_output.get('id')
|
ID2 = json_output.get('id')
|
||||||
self.assertIsNotNone(ID2)
|
self.assertIsNotNone(ID2)
|
||||||
self.assertEqual(
|
self.assertFalse(json_output.get('enabled'))
|
||||||
False,
|
|
||||||
json_output.get('enabled'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
@ -120,10 +111,7 @@ class NetworkFlavorProfileTests(common.NetworkTests):
|
|||||||
))
|
))
|
||||||
ID = json_output_1.get('id')
|
ID = json_output_1.get('id')
|
||||||
self.assertIsNotNone(ID)
|
self.assertIsNotNone(ID)
|
||||||
self.assertEqual(
|
self.assertTrue(json_output_1.get('enabled'))
|
||||||
True,
|
|
||||||
json_output_1.get('enabled'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output_1.get('description'),
|
json_output_1.get('description'),
|
||||||
@ -138,10 +126,7 @@ class NetworkFlavorProfileTests(common.NetworkTests):
|
|||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network flavor profile show -f json ' + ID
|
'network flavor profile show -f json ' + ID
|
||||||
))
|
))
|
||||||
self.assertEqual(
|
self.assertFalse(json_output.get('enabled'))
|
||||||
False,
|
|
||||||
json_output.get('enabled'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
@ -171,10 +156,7 @@ class NetworkFlavorProfileTests(common.NetworkTests):
|
|||||||
ID,
|
ID,
|
||||||
json_output["id"],
|
json_output["id"],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(json_output["enabled"])
|
||||||
True,
|
|
||||||
json_output["enabled"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output["description"],
|
json_output["description"],
|
||||||
|
@ -48,10 +48,7 @@ class TestMeter(common.NetworkTests):
|
|||||||
json_output.get('name'),
|
json_output.get('name'),
|
||||||
)
|
)
|
||||||
# Check if default shared values
|
# Check if default shared values
|
||||||
self.assertEqual(
|
self.assertFalse(json_output.get('shared'))
|
||||||
False,
|
|
||||||
json_output.get('shared'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
@ -67,10 +64,7 @@ class TestMeter(common.NetworkTests):
|
|||||||
json_output_2.get('name'),
|
json_output_2.get('name'),
|
||||||
)
|
)
|
||||||
# Check if default shared values
|
# Check if default shared values
|
||||||
self.assertEqual(
|
self.assertFalse(json_output_2.get('shared'))
|
||||||
False,
|
|
||||||
json_output_2.get('shared'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output_2.get('description'),
|
json_output_2.get('description'),
|
||||||
@ -99,10 +93,7 @@ class TestMeter(common.NetworkTests):
|
|||||||
'Test1',
|
'Test1',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertTrue(json_output.get('shared'))
|
||||||
True,
|
|
||||||
json_output.get('shared'),
|
|
||||||
)
|
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
json_output_2 = json.loads(self.openstack(
|
json_output_2 = json.loads(self.openstack(
|
||||||
@ -117,8 +108,7 @@ class TestMeter(common.NetworkTests):
|
|||||||
'Test2',
|
'Test2',
|
||||||
json_output_2.get('description'),
|
json_output_2.get('description'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(
|
||||||
False,
|
|
||||||
json_output_2.get('shared'),
|
json_output_2.get('shared'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -143,10 +133,7 @@ class TestMeter(common.NetworkTests):
|
|||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter show -f json ' + meter_id
|
'network meter show -f json ' + meter_id
|
||||||
))
|
))
|
||||||
self.assertEqual(
|
self.assertFalse(json_output.get('shared'))
|
||||||
False,
|
|
||||||
json_output.get('shared'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
@ -164,10 +151,7 @@ class TestMeter(common.NetworkTests):
|
|||||||
meter_id,
|
meter_id,
|
||||||
json_output.get('id'),
|
json_output.get('id'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertFalse(json_output.get('shared'))
|
||||||
False,
|
|
||||||
json_output.get('shared'),
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'),
|
json_output.get('description'),
|
||||||
|
@ -247,10 +247,7 @@ class RouterTests(common.NetworkTagTests):
|
|||||||
'router show -f json ' +
|
'router show -f json ' +
|
||||||
new_name
|
new_name
|
||||||
))
|
))
|
||||||
self.assertEqual(
|
self.assertTrue(cmd_output["distributed"])
|
||||||
True,
|
|
||||||
cmd_output["distributed"],
|
|
||||||
)
|
|
||||||
self.assertIsNotNone(cmd_output["external_gateway_info"])
|
self.assertIsNotNone(cmd_output["external_gateway_info"])
|
||||||
|
|
||||||
# Test unset
|
# Test unset
|
||||||
|
Loading…
Reference in New Issue
Block a user