Refactor test cases after adding new params to create_floatingip.
Change-Id: I1feaed67e46edce85397907528e23c4a5f487c1f
diff --git a/neutron_tempest_plugin/api/admin/test_external_network_extension.py b/neutron_tempest_plugin/api/admin/test_external_network_extension.py
index cd4635c..a713492 100644
--- a/neutron_tempest_plugin/api/admin/test_external_network_extension.py
+++ b/neutron_tempest_plugin/api/admin/test_external_network_extension.py
@@ -162,14 +162,12 @@
target_tenant=self.admin_client.tenant_id)
self.create_subnet(net, client=self.admin_client, enable_dhcp=False)
with testtools.ExpectedException(lib_exc.NotFound):
- self.client2.create_floatingip(
- floating_network_id=net['id'])
+ self.create_floatingip(net['id'], client=self.client2)
self.admin_client.create_rbac_policy(
object_type='network', object_id=net['id'],
action='access_as_external',
target_tenant=self.client2.tenant_id)
- self.client2.create_floatingip(
- floating_network_id=net['id'])
+ self.create_floatingip(net['id'], client=self.client2)
@decorators.idempotent_id('476be1e0-f72e-47dc-9a14-4435926bbe82')
def test_policy_allows_tenant_to_attach_ext_gw(self):
diff --git a/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py b/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py
index 3607060..1efe516 100644
--- a/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py
+++ b/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py
@@ -32,7 +32,7 @@
def resource_setup(cls):
super(FloatingIPAdminTestJSON, cls).resource_setup()
cls.ext_net_id = CONF.network.public_network_id
- cls.floating_ip = cls.create_floatingip(cls.ext_net_id)
+ cls.floating_ip = cls.create_floatingip()
cls.alt_client = cls.os_alt.network_client
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
@@ -44,10 +44,7 @@
@decorators.attr(type='negative')
@decorators.idempotent_id('11116ee9-4e99-5b15-b8e1-aa7df92ca589')
def test_associate_floating_ip_with_port_from_another_project(self):
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id)
- floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
+ floating_ip = self.create_floatingip()
project_id = self.create_project()['id']
port = self.admin_client.create_port(network_id=self.network['id'],
@@ -65,20 +62,17 @@
# other tests may end up stealing the IP before we can use it
# since it's on the external network so we need to retry if it's
# in use.
- for i in range(100):
+ for _ in range(100):
fip = self.get_unused_ip(self.ext_net_id, ip_version=4)
try:
- body = self.admin_client.create_floatingip(
- floating_network_id=self.ext_net_id,
- floating_ip_address=fip)
+ created_floating_ip = self.create_floatingip(
+ floating_ip_address=fip,
+ client=self.admin_client)
break
except lib_exc.Conflict:
pass
else:
self.fail("Could not get an unused IP after 100 attempts")
- created_floating_ip = body['floatingip']
- self.addCleanup(self.admin_client.delete_floatingip,
- created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
self.assertEqual(created_floating_ip['floating_ip_address'], fip)
diff --git a/neutron_tempest_plugin/api/admin/test_quotas_negative.py b/neutron_tempest_plugin/api/admin/test_quotas_negative.py
index 7d699d1..cd64e5c 100644
--- a/neutron_tempest_plugin/api/admin/test_quotas_negative.py
+++ b/neutron_tempest_plugin/api/admin/test_quotas_negative.py
@@ -167,11 +167,7 @@
new_quotas = {'floatingip': 1}
self._setup_quotas(tenant_id, **new_quotas)
- ext_net_id = CONF.network.public_network_id
- fip_args = {'tenant_id': tenant_id,
- 'floating_network_id': ext_net_id}
- fip = self.admin_client.create_floatingip(**fip_args)['floatingip']
- self.addCleanup(self.admin_client.delete_floatingip, fip['id'])
+ self.create_floatingip(client=self.admin_client, tenant_id=tenant_id)
- self.assertRaises(lib_exc.Conflict,
- self.admin_client.create_floatingip, **fip_args)
+ self.assertRaises(lib_exc.Conflict, self.create_floatingip,
+ client=self.admin_client, tenant_id=tenant_id)
diff --git a/neutron_tempest_plugin/api/admin/test_tag.py b/neutron_tempest_plugin/api/admin/test_tag.py
index c0210a2..fdcb6a1 100644
--- a/neutron_tempest_plugin/api/admin/test_tag.py
+++ b/neutron_tempest_plugin/api/admin/test_tag.py
@@ -15,7 +15,6 @@
from tempest.lib import exceptions as lib_exc
from neutron_tempest_plugin.api import base
-from neutron_tempest_plugin import config
class TagTestJSON(base.BaseAdminNetworkTest):
@@ -177,9 +176,7 @@
@classmethod
@utils.requires_ext(extension="router", service="network")
def _create_resource(cls):
- cls.ext_net_id = config.CONF.network.public_network_id
- floatingip = cls.create_floatingip(cls.ext_net_id)
- return floatingip['id']
+ return cls.create_floatingip()['id']
@decorators.attr(type='smoke')
@decorators.idempotent_id('53f6c2bf-e272-4e9e-b9a9-b165eb7be807')
@@ -418,9 +415,7 @@
@classmethod
@utils.requires_ext(extension="router", service="network")
def _create_resource(cls):
- cls.ext_net_id = config.CONF.network.public_network_id
- floatingip = cls.create_floatingip(cls.ext_net_id)
- return floatingip['id']
+ return cls.create_floatingip()['id']
def _list_resource(self, filters):
res = self.client.list_floatingips(**filters)
diff --git a/neutron_tempest_plugin/api/test_floating_ips.py b/neutron_tempest_plugin/api/test_floating_ips.py
index 9f5778f..ea3d22e 100644
--- a/neutron_tempest_plugin/api/test_floating_ips.py
+++ b/neutron_tempest_plugin/api/test_floating_ips.py
@@ -48,11 +48,7 @@
# originally the floating IP had no attributes other than its
# association, so an update with an empty body was a signal to
# clear the association. This test ensures we maintain that behavior.
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=self.ports[0]['id'],
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=self.ports[0])
self.assertEqual(self.ports[0]['id'], body['port_id'])
body = self.client.update_floatingip(body['id'])['floatingip']
self.assertFalse(body['port_id'])
@@ -61,12 +57,7 @@
@utils.requires_ext(extension="standard-attr-description",
service="network")
def test_create_update_floatingip_description(self):
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=self.ports[0]['id'],
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=self.ports[0], description='d1')
self.assertEqual('d1', body['description'])
body = self.client.show_floatingip(body['id'])['floatingip']
self.assertEqual('d1', body['description'])
@@ -84,12 +75,7 @@
service="network")
def test_floatingip_update_extra_attributes_port_id_not_changed(self):
port_id = self.ports[1]['id']
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=port_id,
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port_id=port_id, description='d1')
self.assertEqual('d1', body['description'])
body = self.client.show_floatingip(body['id'])['floatingip']
self.assertEqual(port_id, body['port_id'])
@@ -112,12 +98,7 @@
@utils.requires_ext(extension="fip-port-details", service="network")
def test_create_update_floatingip_port_details(self):
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=self.ports[0]['id'],
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=self.ports[0], description='d1')
self._assert_port_details(self.ports[0], body)
body = self.client.show_floatingip(body['id'])['floatingip']
self._assert_port_details(self.ports[0], body)
diff --git a/neutron_tempest_plugin/api/test_floating_ips_negative.py b/neutron_tempest_plugin/api/test_floating_ips_negative.py
index 453af71..c8b8cb4 100644
--- a/neutron_tempest_plugin/api/test_floating_ips_negative.py
+++ b/neutron_tempest_plugin/api/test_floating_ips_negative.py
@@ -53,14 +53,8 @@
self.addCleanup(self.client.update_router, self.router['id'],
external_gateway_info={})
port = self.create_port(net)
- body1 = self.client.create_floatingip(
- floating_network_id=self.ext_net_id)
- floating_ip1 = body1['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip1['id'])
- body2 = self.client.create_floatingip(
- floating_network_id=self.ext_net_id)
- floating_ip2 = body2['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip2['id'])
+ floating_ip1 = self.create_floatingip()
+ floating_ip2 = self.create_floatingip()
self.client.update_floatingip(floating_ip1['id'],
port_id=port['id'])
self.assertRaises(lib_exc.Conflict, self.client.update_floatingip,
diff --git a/neutron_tempest_plugin/api/test_revisions.py b/neutron_tempest_plugin/api/test_revisions.py
index eb32560..b03285d 100644
--- a/neutron_tempest_plugin/api/test_revisions.py
+++ b/neutron_tempest_plugin/api/test_revisions.py
@@ -309,7 +309,7 @@
@decorators.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
@utils.requires_ext(extension="router", service="network")
@utils.requires_ext(extension="standard-attr-description",
- service="network")
+ service="network")
def test_update_floatingip_bumps_revision(self):
ext_id = config.CONF.network.public_network_id
net = self.create_network()
@@ -325,12 +325,7 @@
subnet['id'])
port = self.create_port(net)
self.addCleanup(self.client.delete_port, port['id'])
- body = self.client.create_floatingip(
- floating_network_id=ext_id,
- port_id=port['id'],
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=port, description='d1')
self.assertIn('revision_number', body)
b2 = self.client.update_floatingip(body['id'], description='d2')
self.assertGreater(b2['floatingip']['revision_number'],
diff --git a/neutron_tempest_plugin/api/test_timestamp.py b/neutron_tempest_plugin/api/test_timestamp.py
index 186d21f..f5888f9 100644
--- a/neutron_tempest_plugin/api/test_timestamp.py
+++ b/neutron_tempest_plugin/api/test_timestamp.py
@@ -247,14 +247,14 @@
@decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
def test_create_floatingip_with_timestamp(self):
- fip = self.create_floatingip(self.ext_net_id)
+ fip = self.create_floatingip()
# Verifies body contains timestamp fields
self.assertIsNotNone(fip['created_at'])
self.assertIsNotNone(fip['updated_at'])
@decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
def test_update_floatingip_with_timestamp(self):
- fip = self.create_floatingip(self.ext_net_id)
+ fip = self.create_floatingip()
origin_updated_at = fip['updated_at']
update_body = {'description': 'new'}
body = self.client.update_floatingip(fip['id'], **update_body)
@@ -266,7 +266,7 @@
@decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
def test_show_floatingip_attribute_with_timestamp(self):
- fip = self.create_floatingip(self.ext_net_id)
+ fip = self.create_floatingip()
body = self.client.show_floatingip(fip['id'])
show_fip = body['floatingip']
# verify the timestamp from creation and showed is same