From fab88225ab88bcc7727aadb908746943cbca4bee Mon Sep 17 00:00:00 2001 From: pkomarov Date: Mon, 8 Apr 2019 00:49:34 +0300 Subject: [PATCH] Substitude class attribute 'parameters' dict to an easier to read individual class attributes. class FloatingIPFixture(heat.HeatStackFixture): [...] parameters = {'floating_network': CONF.tobiko.neutron.floating_network, 'image': CONF.tobiko.nova.image, 'flavor': CONF.tobiko.nova.flavor} --> class FloatingIPFixture(heat.HeatStackFixture): [...] floating_network = CONF.tobiko.neutron.floating_network image = CONF.tobiko.nova.image, flavor = CONF.tobiko.nova.flavor Change-Id: Ia3f3d6cb21de941426fedb936541d89d2923131d --- tobiko/openstack/heat/_stack.py | 8 ++++++++ tobiko/tests/scenario/neutron/base.py | 4 +--- tobiko/tests/scenario/neutron/test_floating_ip.py | 10 +++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tobiko/openstack/heat/_stack.py b/tobiko/openstack/heat/_stack.py index 5a1202853..b0e29a185 100644 --- a/tobiko/openstack/heat/_stack.py +++ b/tobiko/openstack/heat/_stack.py @@ -109,6 +109,14 @@ class HeatStackFixture(tobiko.SharedFixture): if self._parameters: self.parameters.update(self._parameters) + # Add template's missing stack parameters + if 'parameters' in self.template.template: + for name in self.template.template['parameters']: + if name not in self.parameters: + value = getattr(self, name, None) + if value is not None: + self.parameters[name] = value + def setup_client(self): client_fixture = self.client_fixture if client_fixture: diff --git a/tobiko/tests/scenario/neutron/base.py b/tobiko/tests/scenario/neutron/base.py index df9c4c859..3c99130be 100644 --- a/tobiko/tests/scenario/neutron/base.py +++ b/tobiko/tests/scenario/neutron/base.py @@ -34,9 +34,7 @@ def heat_template_file(template_file): class InternalNetworkFixture(heat.HeatStackFixture): template = heat_template_file('internal_network.yaml') - parameters = { - 'floating_network': CONF.tobiko.neutron.floating_network, - } + floating_network = CONF.tobiko.neutron.floating_network class SecurityGroupsFixture(heat.HeatStackFixture): diff --git a/tobiko/tests/scenario/neutron/test_floating_ip.py b/tobiko/tests/scenario/neutron/test_floating_ip.py index 5490f47f6..020a72b5f 100644 --- a/tobiko/tests/scenario/neutron/test_floating_ip.py +++ b/tobiko/tests/scenario/neutron/test_floating_ip.py @@ -26,9 +26,9 @@ CONF = config.CONF class FloatingIPFixture(heat.HeatStackFixture): template = base.heat_template_file('floating_ip.yaml') - parameters = {'floating_network': CONF.tobiko.neutron.floating_network, - 'image': CONF.tobiko.nova.image, - 'flavor': CONF.tobiko.nova.flavor} + floating_network = CONF.tobiko.neutron.floating_network + image = CONF.tobiko.nova.image + flavor = CONF.tobiko.nova.flavor internal_network_fixture = base.InternalNetworkFixture internal_network = None @@ -43,11 +43,11 @@ class FloatingIPFixture(heat.HeatStackFixture): class FloatingIPWithPortSecurityFixture(FloatingIPFixture): - parameters = {'port_security_enabled': True} + port_security_enabled = True class FloatingIPWithSecurityGroupFixture(FloatingIPFixture): - parameters = {'port_security_enabled': True} + port_security_enabled = True security_groups_fixture = base.SecurityGroupsFixture security_groups = None