Merge "Use assertIn and assertNotIn"
This commit is contained in:
commit
a17ad90d6c
@ -128,7 +128,7 @@ class TestKuryrJoinFailures(base.TestKuryrFailures):
|
||||
self.assertEqual(
|
||||
w_exceptions.BadRequest.code, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
# TODO(tfukushima): Add the better error message validation.
|
||||
self.assertTrue(invalid_docker_endpoint_id in decoded_json['Err'])
|
||||
self.assertTrue('EndpointID' in decoded_json['Err'])
|
||||
self.assertIn(invalid_docker_endpoint_id, decoded_json['Err'])
|
||||
self.assertIn('EndpointID', decoded_json['Err'])
|
||||
|
@ -199,7 +199,7 @@ class TestKuryr(base.TestKuryrBase):
|
||||
# should be contained in the response.
|
||||
self.assertNotEqual(expected, decoded_json)
|
||||
app.logger.debug(decoded_json)
|
||||
self.assertTrue('Address' in decoded_json['Interface'])
|
||||
self.assertIn('Address', decoded_json['Interface'])
|
||||
|
||||
def test_network_driver_create_endpoint_with_subnetpools(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
@ -310,8 +310,8 @@ class TestKuryr(base.TestKuryrBase):
|
||||
# Address and AddressIPv6, allocated by Neutron's IPAM automatically
|
||||
# should be contained in the response.
|
||||
self.assertNotEqual(expected, decoded_json)
|
||||
self.assertTrue('Address' in decoded_json['Interface'])
|
||||
self.assertTrue('AddressIPv6' in decoded_json['Interface'])
|
||||
self.assertIn('Address', decoded_json['Interface'])
|
||||
self.assertIn('AddressIPv6', decoded_json['Interface'])
|
||||
|
||||
def test_network_driver_create_endpoint(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
|
@ -188,7 +188,7 @@ class TestKuryrEndpointCreateFailures(TestKuryrEndpointFailures):
|
||||
|
||||
self.assertEqual(GivenException.status_code, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertEqual({'Err': GivenException.message}, decoded_json)
|
||||
|
||||
@ddt.data(exceptions.Unauthorized, exceptions.Forbidden,
|
||||
@ -227,7 +227,7 @@ class TestKuryrEndpointCreateFailures(TestKuryrEndpointFailures):
|
||||
|
||||
self.assertEqual(GivenException.status_code, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertEqual({'Err': GivenException.message}, decoded_json)
|
||||
|
||||
def test_create_endpoint_bad_request(self):
|
||||
@ -240,10 +240,10 @@ class TestKuryrEndpointCreateFailures(TestKuryrEndpointFailures):
|
||||
|
||||
self.assertEqual(400, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
# TODO(tfukushima): Add the better error message validation.
|
||||
self.assertTrue(invalid_docker_endpoint_id in decoded_json['Err'])
|
||||
self.assertTrue('EndpointID' in decoded_json['Err'])
|
||||
self.assertIn(invalid_docker_endpoint_id, decoded_json['Err'])
|
||||
self.assertIn('EndpointID', decoded_json['Err'])
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@ -329,7 +329,7 @@ class TestKuryrEndpointDeleteFailures(TestKuryrEndpointFailures):
|
||||
else:
|
||||
self.assertEqual(GivenException.status_code, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertEqual({'Err': GivenException.message}, decoded_json)
|
||||
|
||||
@ddt.data(exceptions.Unauthorized, exceptions.NotFound,
|
||||
@ -359,7 +359,7 @@ class TestKuryrEndpointDeleteFailures(TestKuryrEndpointFailures):
|
||||
|
||||
self.assertEqual(GivenException.status_code, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertEqual({'Err': GivenException.message}, decoded_json)
|
||||
|
||||
def test_delete_endpoint_bad_request(self):
|
||||
@ -372,7 +372,7 @@ class TestKuryrEndpointDeleteFailures(TestKuryrEndpointFailures):
|
||||
|
||||
self.assertEqual(400, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
# TODO(tfukushima): Add the better error message validation.
|
||||
self.assertTrue(invalid_docker_endpoint_id in decoded_json['Err'])
|
||||
self.assertTrue('EndpointID' in decoded_json['Err'])
|
||||
self.assertIn(invalid_docker_endpoint_id, decoded_json['Err'])
|
||||
self.assertIn('EndpointID', decoded_json['Err'])
|
||||
|
@ -57,7 +57,7 @@ class TestKuryrNetworkCreateFailures(base.TestKuryrFailures):
|
||||
|
||||
self.assertEqual(401, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertEqual(
|
||||
{'Err': exceptions.Unauthorized.message}, decoded_json)
|
||||
|
||||
@ -67,10 +67,10 @@ class TestKuryrNetworkCreateFailures(base.TestKuryrFailures):
|
||||
|
||||
self.assertEqual(400, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
# TODO(tfukushima): Add the better error message validation.
|
||||
self.assertTrue(invalid_docker_network_id in decoded_json['Err'])
|
||||
self.assertTrue('NetworkID' in decoded_json['Err'])
|
||||
self.assertIn(invalid_docker_network_id, decoded_json['Err'])
|
||||
self.assertIn('NetworkID', decoded_json['Err'])
|
||||
|
||||
|
||||
@ddt
|
||||
@ -120,7 +120,7 @@ class TestKuryrNetworkDeleteFailures(base.TestKuryrFailures):
|
||||
|
||||
self.assertEqual(GivenException.status_code, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertEqual({'Err': GivenException.message}, decoded_json)
|
||||
|
||||
def test_delete_network_bad_request(self):
|
||||
@ -130,6 +130,6 @@ class TestKuryrNetworkDeleteFailures(base.TestKuryrFailures):
|
||||
|
||||
self.assertEqual(400, response.status_code)
|
||||
decoded_json = jsonutils.loads(response.data)
|
||||
self.assertTrue('Err' in decoded_json)
|
||||
self.assertTrue(invalid_docker_network_id in decoded_json['Err'])
|
||||
self.assertTrue('NetworkID' in decoded_json['Err'])
|
||||
self.assertIn('Err', decoded_json)
|
||||
self.assertIn(invalid_docker_network_id, decoded_json['Err'])
|
||||
self.assertIn('NetworkID', decoded_json['Err'])
|
||||
|
@ -35,5 +35,5 @@ class TestKuryrUtils(base.TestKuryrBase):
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
generated_neutron_port_name = utils.get_neutron_port_name(
|
||||
fake_docker_endpoint_id)
|
||||
self.assertTrue(utils.PORT_POSTFIX in generated_neutron_port_name)
|
||||
self.assertTrue(fake_docker_endpoint_id in generated_neutron_port_name)
|
||||
self.assertIn(utils.PORT_POSTFIX, generated_neutron_port_name)
|
||||
self.assertIn(fake_docker_endpoint_id, generated_neutron_port_name)
|
||||
|
Loading…
Reference in New Issue
Block a user