431
434
parser.Template({}), env=env,
432
435
stack_id=uuidutils.generate_uuid())
434
self.assertRaises(ValueError,
435
template_resource.TemplateResource,
437
{"Type": 'Test::Flippy'},
437
temp_res = template_resource.TemplateResource('test_t_res',
438
{"Type": 'Test::Flippy'},
441
self.assertRaises(exception.StackValidationFailed, temp_res.validate)
443
def test_system_template_retrieve_fail(self):
444
# make sure that a TemplateResource defined in the global environment
445
# fails gracefully if the template file specified is inaccessible
446
# we should be able to create the TemplateResource object, but
447
# validation should fail, when the second attempt to access it is
449
g_env = resources.global_env()
450
test_templ_name = 'file:///etc/heatr/frodo.yaml'
451
g_env.load({'resource_registry':
452
{'Test::Frodo': test_templ_name}})
453
stack = parser.Stack(utils.dummy_context(), 'test_stack',
455
stack_id=uuidutils.generate_uuid())
457
self.m.StubOutWithMock(urlfetch, "get")
458
urlfetch.get(test_templ_name,
459
allowed_schemes=('http', 'https',
460
'file')).AndRaise(IOError)
461
urlfetch.get(test_templ_name,
462
allowed_schemes=('http', 'https',
463
'file')).AndRaise(IOError)
466
temp_res = template_resource.TemplateResource('test_t_res',
467
{"Type": 'Test::Frodo'},
469
self.assertRaises(exception.StackValidationFailed, temp_res.validate)
472
def test_user_template_retrieve_fail(self):
473
# make sure that a TemplateResource defined in the user environment
474
# fails gracefully if the template file specified is inaccessible
475
# we should be able to create the TemplateResource object, but
476
# validation should fail, when the second attempt to access it is
478
env = environment.Environment()
479
test_templ_name = 'http://heatr/noexist.yaml'
480
env.load({'resource_registry':
481
{'Test::Flippy': test_templ_name}})
482
stack = parser.Stack(utils.dummy_context(), 'test_stack',
483
parser.Template({}), env=env,
484
stack_id=uuidutils.generate_uuid())
486
self.m.StubOutWithMock(urlfetch, "get")
487
urlfetch.get(test_templ_name,
488
allowed_schemes=('http', 'https')).AndRaise(IOError)
489
urlfetch.get(test_templ_name,
490
allowed_schemes=('http', 'https')).AndRaise(IOError)
493
temp_res = template_resource.TemplateResource('test_t_res',
494
{"Type": 'Test::Flippy'},
496
self.assertRaises(exception.StackValidationFailed, temp_res.validate)