Merge "Use self.create_port instead of client.create_port"

This commit is contained in:
Zuul 2018-12-15 03:12:33 +00:00 committed by Gerrit Code Review
commit 1c0fcfe496
5 changed files with 19 additions and 27 deletions

View File

@ -101,8 +101,7 @@ class SharedNetworksTest(base.BaseAdminNetworkTest):
@decorators.idempotent_id('9c31fabb-0181-464f-9ace-95144fe9ca77')
def test_create_port_shared_network_as_non_admin_tenant(self):
# create a port as non admin
body = self.client.create_port(network_id=self.shared_network['id'])
port = body['port']
port = self.create_port(self.shared_network)
self.addCleanup(self.admin_client.delete_port, port['id'])
# verify the tenant id of admin network and non admin port
self.assertNotEqual(self.shared_network['tenant_id'],
@ -257,7 +256,7 @@ class RBACSharedNetworksTest(base.BaseAdminNetworkTest):
def test_port_presence_prevents_network_rbac_policy_deletion(self):
res = self._make_admin_net_and_subnet_shared_to_tenant_id(
self.client.tenant_id)
port = self.client.create_port(network_id=res['network']['id'])['port']
port = self.create_port(res['network'])
# a port on the network should prevent the deletion of a policy
# required for it to exist
with testtools.ExpectedException(lib_exc.Conflict):
@ -274,7 +273,7 @@ class RBACSharedNetworksTest(base.BaseAdminNetworkTest):
object_type='network', object_id=net['id'],
action='access_as_shared',
target_tenant=net['tenant_id'])['rbac_policy']
port = self.client.create_port(network_id=net['id'])['port']
port = self.create_port(net)
self.client.delete_rbac_policy(self_share['id'])
self.client.delete_port(port['id'])
@ -290,8 +289,7 @@ class RBACSharedNetworksTest(base.BaseAdminNetworkTest):
@decorators.idempotent_id('f7539232-389a-4e9c-9e37-e42a129eb541')
def test_tenant_cant_delete_other_tenants_ports(self):
net = self.create_network()
port = self.client.create_port(network_id=net['id'])['port']
self.addCleanup(self.client.delete_port, port['id'])
port = self.create_port(net)
with testtools.ExpectedException(lib_exc.NotFound):
self.client2.delete_port(port['id'])
@ -405,7 +403,7 @@ class RBACSharedNetworksTest(base.BaseAdminNetworkTest):
object_type='network', object_id=net['id'],
action='access_as_shared',
target_tenant=net['tenant_id'])['rbac_policy']
port = self.client.create_port(network_id=net['id'])['port']
port = self.create_port(net)
self.client.update_rbac_policy(self_share['id'],
target_tenant=self.client2.tenant_id)
self.client.delete_port(port['id'])

View File

@ -53,11 +53,10 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
# Create port with allowed address pair attribute
allowed_address_pairs = [{'ip_address': self.ip_address,
'mac_address': self.mac_address}]
body = self.client.create_port(
network_id=self.network['id'],
body = self.create_port(
self.network,
allowed_address_pairs=allowed_address_pairs)
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
port_id = body['id']
# Confirm port was created with allowed address pair attribute
body = self.client.list_ports()
@ -69,9 +68,8 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
def _update_port_with_address(self, address, mac_address=None, **kwargs):
# Create a port without allowed address pair
body = self.client.create_port(network_id=self.network['id'])
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
body = self.create_port(self.network)
port_id = body['id']
if mac_address is None:
mac_address = self.mac_address
@ -99,11 +97,9 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
@decorators.idempotent_id('b3f20091-6cd5-472b-8487-3516137df933')
def test_update_port_with_multiple_ip_mac_address_pair(self):
# Create an ip _address and mac_address through port create
resp = self.client.create_port(network_id=self.network['id'])
newportid = resp['port']['id']
self.addCleanup(self.client.delete_port, newportid)
ipaddress = resp['port']['fixed_ips'][0]['ip_address']
macaddress = resp['port']['mac_address']
resp = self.create_port(self.network)
ipaddress = resp['fixed_ips'][0]['ip_address']
macaddress = resp['mac_address']
# Update allowed address pair port with multiple ip and mac
allowed_address_pairs = {'ip_address': ipaddress,

View File

@ -56,11 +56,10 @@ class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
@decorators.idempotent_id('d2c17063-3767-4a24-be4f-a23dbfa133c9')
def test_create_list_port_with_extra_dhcp_options(self):
# Create a port with Extra DHCP Options
body = self.client.create_port(
network_id=self.network['id'],
body = self.create_port(
self.network,
extra_dhcp_opts=self.extra_dhcp_opts)
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
port_id = body['id']
# Confirm port created has Extra DHCP Options
body = self.client.list_ports()

View File

@ -28,8 +28,7 @@ class NetworksNegativeTest(base.BaseNetworkTest):
@decorators.attr(type='negative')
@decorators.idempotent_id('9f80f25b-5d1b-4f26-9f6b-774b9b270819')
def test_delete_network_in_use(self):
port = self.client.create_port(network_id=self.network['id'])
self.addCleanup(self.client.delete_port, port['port']['id'])
self.create_port(self.network)
with testtools.ExpectedException(lib_exc.Conflict):
self.client.delete_subnet(self.subnet['id'])
with testtools.ExpectedException(lib_exc.Conflict):

View File

@ -39,9 +39,9 @@ class RoutersNegativeTest(RoutersNegativeTestBase):
@decorators.idempotent_id('e3e751af-15a2-49cc-b214-a7154579e94f')
def test_delete_router_in_use(self):
# This port is deleted after a test by remove_router_interface.
port = self.client.create_port(network_id=self.network['id'])
port = self.create_port(self.network)
self.client.add_router_interface_with_port_id(
self.router['id'], port['port']['id'])
self.router['id'], port['id'])
with testtools.ExpectedException(lib_exc.Conflict):
self.client.delete_router(self.router['id'])