Fix missing import with new test

The error message was created without proper import and test. Add it
with new test.

Change-Id: Id6b63e9c1831bd2a1210b30946efb4febb1cc8d8
Closes-Bug: #1502937
This commit is contained in:
spzala
2015-11-19 13:23:40 -08:00
parent 76e216a1c8
commit a2c5ba1ab9
2 changed files with 14 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import InvalidSchemaError
from toscaparser.utils.gettextutils import _
class PropertyDef(object):

View File

@@ -11,6 +11,7 @@
# under the License.
from toscaparser.common import exception
from toscaparser.elements.property_definition import PropertyDef
from toscaparser.properties import Property
from toscaparser.tests.base import TestCase
from toscaparser.utils.gettextutils import _
@@ -221,3 +222,15 @@ class PropertyTest(TestCase):
self.assertIsNone(tpl.validate())
self.assertEqual(expected_properties,
sorted(tpl.get_properties().keys()))
def test_missing_property_type(self):
tpl_snippet = '''
properties:
prop:
typo: tosca.mytesttype.Test
'''
schema = yamlparser.simple_parse(tpl_snippet)
error = self.assertRaises(exception.InvalidSchemaError, PropertyDef,
'prop', None, schema['properties']['prop'])
self.assertEqual(_('Property definition of "prop" '
'must have a "type" attribute.'), str(error))