1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
20
from heatclient.common import template_format
23
load_tests = testscenarios.load_tests_apply_scenarios
26
class YamlParseExceptions(testtools.TestCase):
29
('scanner', dict(raised_exception=yaml.scanner.ScannerError())),
30
('parser', dict(raised_exception=yaml.parser.ParserError())),
32
dict(raised_exception=yaml.reader.ReaderError('', '', '', '', ''))),
35
def test_parse_to_value_exception(self):
36
text = 'not important'
38
with mock.patch.object(yaml, 'load') as yaml_loader:
39
yaml_loader.side_effect = self.raised_exception
41
self.assertRaises(ValueError,
42
template_format.parse, text)
44
def test_parse_no_version_format(self):
46
self.assertRaises(ValueError, template_format.parse, yaml)
47
yaml2 = '''Parameters: {}
52
self.assertRaises(ValueError, template_format.parse, yaml2)