Don't use MagicMock for stacks in tests
Conflict resolution was required because the test_needs_replace_failed
test doesn't exist on this branch
Change-Id: I1ac42a3057dea4d6a19b7e6d73cf1152a0b6ba7d
Closes-Bug: #1656190
(cherry picked from commit 3227b1d907
)
This commit is contained in:
parent
eab58cb813
commit
e83c1a419a
@ -16,12 +16,14 @@ from neutronclient.common import exceptions as qe
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine.clients.os import neutron
|
||||
from heat.engine import properties
|
||||
from heat.engine.resources.openstack.neutron import net
|
||||
from heat.engine.resources.openstack.neutron import neutron as nr
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import stack
|
||||
from heat.engine import template
|
||||
from heat.tests import common
|
||||
from heat.tests import utils
|
||||
|
||||
|
||||
class NeutronTest(common.HeatTestCase):
|
||||
@ -73,7 +75,7 @@ class NeutronTest(common.HeatTestCase):
|
||||
'FROBULATING due to "Unknown"',
|
||||
six.text_type(e))
|
||||
|
||||
def test_resolve_attribute(self):
|
||||
def _get_some_neutron_resource(self):
|
||||
class SomeNeutronResource(nr.NeutronResource):
|
||||
properties_schema = {}
|
||||
|
||||
@ -81,20 +83,23 @@ class NeutronTest(common.HeatTestCase):
|
||||
def is_service_available(cls, context):
|
||||
return (True, None)
|
||||
|
||||
empty_tmpl = {'heat_template_version': '2016-10-14'}
|
||||
tmpl = template.Template(empty_tmpl)
|
||||
stack_name = 'dummystack'
|
||||
self.dummy_stack = stack.Stack(utils.dummy_context(), stack_name, tmpl)
|
||||
|
||||
tmpl = rsrc_defn.ResourceDefinition('test_res', 'Foo')
|
||||
stack = mock.MagicMock()
|
||||
stack.has_cache_data = mock.Mock(return_value=False)
|
||||
res = SomeNeutronResource('aresource', tmpl, stack)
|
||||
|
||||
mock_show_resource = mock.MagicMock()
|
||||
mock_show_resource.side_effect = [{'attr1': 'val1', 'attr2': 'val2'},
|
||||
{'attr1': 'val1', 'attr2': 'val2'},
|
||||
{'attr1': 'val1', 'attr2': 'val2'},
|
||||
qe.NotFound]
|
||||
res._show_resource = mock_show_resource
|
||||
nclientplugin = neutron.NeutronClientPlugin(mock.MagicMock())
|
||||
res.client_plugin = mock.Mock(return_value=nclientplugin)
|
||||
self.dummy_stack.has_cache_data = mock.Mock(return_value=False)
|
||||
return SomeNeutronResource('aresource', tmpl, self.dummy_stack)
|
||||
|
||||
def test_resolve_attribute(self):
|
||||
res = self._get_some_neutron_resource()
|
||||
side_effect = [{'attr1': 'val1', 'attr2': 'val2'},
|
||||
{'attr1': 'val1', 'attr2': 'val2'},
|
||||
{'attr1': 'val1', 'attr2': 'val2'},
|
||||
qe.NotFound]
|
||||
self.patchobject(res, '_show_resource', side_effect=side_effect)
|
||||
res.resource_id = 'resource_id'
|
||||
self.assertEqual({'attr1': 'val1', 'attr2': 'val2'},
|
||||
res.FnGetAtt('show'))
|
||||
self.assertEqual('val2', res._resolve_all_attributes('attr2'))
|
||||
|
Loading…
Reference in New Issue
Block a user