Fix and test the validation of template file

The validation message is created without proper import. Add it with new test.

Change-Id: Ia8a815e5f4b4c267e8a96faeebe8b5f9afe2b364
Partial-Bug: #1502937
This commit is contained in:
spzala
2015-11-05 21:00:51 -08:00
parent ecf5a439ad
commit fa0cd927eb
2 changed files with 9 additions and 0 deletions

View File

@@ -448,3 +448,11 @@ class ToscaTemplateTest(TestCase):
'TestRsyslogType']
self.assertItemsEqual(tosca.topology_template.custom_defs.keys(),
expected_custom_types)
def test_invalid_template_file(self):
template_file = 'invalid template file'
expected_msg = ('%s is not a valid file.' % template_file)
err = self.assertRaises(
ValueError,
lambda: ToscaTemplate(template_file, None, False))
self.assertEqual(expected_msg, err.__str__())

View File

@@ -21,6 +21,7 @@ import toscaparser.imports
from toscaparser.prereq.csar import CSAR
from toscaparser.topology_template import TopologyTemplate
from toscaparser.tpl_relationship_graph import ToscaGraph
from toscaparser.utils.gettextutils import _
import toscaparser.utils.yamlparser