Make global TemplateResources usable in the tests

At the moment we need the templates installed into /etc/heat/templates
and this is not very nice for the tests. So this patch
replaces "/etc/heat/templates" with the project's own template
path so we can at least test the api of the template resources.

Partial-Bug: #1215797
Change-Id: Ie4924b0358b97af8feaad93ed9187976b8932e3d
This commit is contained in:
Angus Salkeld 2013-09-05 19:50:08 +10:00 committed by Steve Baker
parent e884ae5057
commit 5fc4d75cf5
1 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,8 @@ import testtools
from oslo.config import cfg
import heat.engine.scheduler as scheduler
from heat.engine import environment
from heat.engine import resources
class HeatTestCase(testtools.TestCase):
@ -46,3 +48,13 @@ class HeatTestCase(testtools.TestCase):
cfg.CONF.set_default('environment_dir', env_dir)
self.addCleanup(cfg.CONF.reset)
tri = resources.global_env().get_resource_info(
'AWS::RDS::DBInstance',
registry_type=environment.TemplateResourceInfo)
if tri is not None:
cur_path = tri.template_name
templ_path = os.path.join(project_dir, 'etc', 'heat', 'templates')
if templ_path not in cur_path:
tri.template_name = cur_path.replace('/etc/heat/templates',
templ_path)