summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/conf.py1
-rw-r--r--docs/conf.yaml3
-rw-r--r--docs/index.rst17
-rw-r--r--docs/release/userguide/feature.userguide.rst2
-rw-r--r--docs/requirements.txt2
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py2
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/tosca_type_validation.py4
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/data/custom_types/invalid_type.yaml8
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/data/test_import_invalid_type.yaml11
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/test_properties.py29
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py11
-rw-r--r--tox.ini12
12 files changed, 97 insertions, 5 deletions
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..3c4453e
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1 @@
+from docs_conf.conf import *
diff --git a/docs/conf.yaml b/docs/conf.yaml
new file mode 100644
index 0000000..e2c35e6
--- /dev/null
+++ b/docs/conf.yaml
@@ -0,0 +1,3 @@
+---
+project_cfg: opnfv
+project: parser
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..b2c3b5d
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,17 @@
+.. This work is licensed under a Creative Commons Attribution 4.0
+.. International License.
+.. SPDX-License-Identifier: CC-BY-4.0
+.. (c) Open Platform for NFV Project, Inc. and its contributors
+
+.. _parser:
+
+======
+Parser
+======
+
+.. toctree::
+ :maxdepth: 2
+
+ release/installation/index
+ release/release-notes/index
+ release/userguide/index
diff --git a/docs/release/userguide/feature.userguide.rst b/docs/release/userguide/feature.userguide.rst
index 4d0d46e..4ad4f22 100644
--- a/docs/release/userguide/feature.userguide.rst
+++ b/docs/release/userguide/feature.userguide.rst
@@ -71,7 +71,7 @@ Using api, which is used to parse and get the result of service template. it can
ToscaTemplate(path=None, parsed_params=None, a_file=True, yaml_dict_tpl=None,
sub_mapped_node_template=None,
- no_required_paras_valid=False, debug=False )
+ no_required_paras_valid=False, debug=False)
REST API
*********
diff --git a/docs/requirements.txt b/docs/requirements.txt
new file mode 100644
index 0000000..9fde2df
--- /dev/null
+++ b/docs/requirements.txt
@@ -0,0 +1,2 @@
+lfdocs-conf
+sphinx_opnfv_theme
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
index 23c5afc..c37aa9d 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
@@ -35,7 +35,7 @@ class CapabilityTypeDef(StatefulEntityType):
parent_properties = {}
if self.parent_capabilities:
for type, value in self.parent_capabilities.items():
- parent_properties[type] = value.get('properties')
+ parent_properties[type] = value.get('properties', {})
if self.properties:
for prop, schema in self.properties.items():
properties.append(PropertyDef(prop, None, schema))
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/tosca_type_validation.py b/tosca2heat/tosca-parser/toscaparser/elements/tosca_type_validation.py
index 89a6a03..8b49f48 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/tosca_type_validation.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/tosca_type_validation.py
@@ -49,12 +49,12 @@ class TypeValidation(object):
for name in custom_type:
if name not in self.ALLOWED_TYPE_SECTIONS:
ExceptionCollector.appendException(
- UnknownFieldError(what='Template ' + (self.import_def),
+ UnknownFieldError(what='Template ' + str(self.import_def),
field=name))
def _validate_type_version(self, version):
if version not in self.VALID_TEMPLATE_VERSIONS:
ExceptionCollector.appendException(
InvalidTemplateVersion(
- what=version + ' in ' + self.import_def,
+ what=version + ' in ' + str(self.import_def),
valid_versions=', '. join(self.VALID_TEMPLATE_VERSIONS)))
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/data/custom_types/invalid_type.yaml b/tosca2heat/tosca-parser/toscaparser/tests/data/custom_types/invalid_type.yaml
new file mode 100644
index 0000000..4d3a0b0
--- /dev/null
+++ b/tosca2heat/tosca-parser/toscaparser/tests/data/custom_types/invalid_type.yaml
@@ -0,0 +1,8 @@
+tosca_definitions_version: tosca_simple_yaml_1_1
+
+annotation_types:
+ org.openecomp.annotations.Source:
+ description: Indicates the origin source of an input
+ properties:
+ source_type:
+ type: string
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/data/test_import_invalid_type.yaml b/tosca2heat/tosca-parser/toscaparser/tests/data/test_import_invalid_type.yaml
new file mode 100644
index 0000000..f2c1876
--- /dev/null
+++ b/tosca2heat/tosca-parser/toscaparser/tests/data/test_import_invalid_type.yaml
@@ -0,0 +1,11 @@
+tosca_definitions_version: tosca_simple_yaml_1_1
+
+imports:
+ - invalid: custom_types/invalid_type.yaml
+
+description: Test to import a template with an invalid type.
+
+topology_template:
+ node_templates:
+ test:
+ type: tosca.nodes.Root
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py b/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py
index 6b95537..faa8af4 100644
--- a/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py
+++ b/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py
@@ -314,6 +314,31 @@ class PropertyTest(TestCase):
num_cpus: 1
'''
+ tosca_custom_def_example3 = '''
+ tosca.capabilities.New:
+ derived_from: tosca.capabilities.Node
+ properties:
+ test_case:
+ type: integer
+ required: yes
+
+ tosca.nodes.ComputeNew:
+ derived_from: tosca.nodes.Compute
+ capabilities:
+ scalable:
+ type: tosca.capabilities.New
+ '''
+
+ tosca_node_template_example3 = '''
+ node_templates:
+ compute_instance:
+ type: tosca.nodes.ComputeNew
+ capabilities:
+ scalable:
+ properties:
+ test_case: 1
+ '''
+
tpl1 = self._get_nodetemplate(tosca_node_template_example1,
tosca_custom_def_example1)
self.assertIsNone(tpl1.validate())
@@ -322,6 +347,10 @@ class PropertyTest(TestCase):
tosca_custom_def_example2)
self.assertIsNone(tpl2.validate())
+ tpl3 = self._get_nodetemplate(tosca_node_template_example3,
+ tosca_custom_def_example3)
+ self.assertIsNone(tpl3.validate())
+
def _get_nodetemplate(self, tpl_snippet,
custom_def_snippet=None):
nodetemplates = yamlparser.\
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py b/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
index a8b1590..ea27bcb 100644
--- a/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
+++ b/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
@@ -1442,6 +1442,17 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml
(_('The template version "tosca_xyz" is invalid. Valid versions '
'are "%s".') % valid_versions))
+ def test_import_invalid_type(self):
+ tosca_tpl = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ "data/test_import_invalid_type.yaml")
+ self.assertRaises(exception.ValidationError, ToscaTemplate, tosca_tpl)
+ exception.ExceptionCollector.assertExceptionMessage(
+ exception.UnknownFieldError,
+ (_("Template {'invalid': 'custom_types/invalid_type.yaml'} "
+ 'contains unknown field "annotation_types". Refer to the '
+ 'definition to verify valid values.')))
+
def test_node_template_capabilities_properties(self):
# validating capability property values
tpl_snippet = '''
diff --git a/tox.ini b/tox.ini
index c4b1b0f..9b755ff 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,7 +2,7 @@
# such as verigraph
[tox]
minversion = 1.6
-envlist = py27,pep8
+envlist = py27,pep8,docs,docs-linkcheck
skipsdist = True
[testenv]
@@ -24,3 +24,13 @@ whitelist_externals =
commands =
bash -c 'cd tosca2heat/tosca-parser; tox'
+[testenv:docs]
+usedevelop = False
+deps = -rdocs/requirements.txt
+commands =
+ sphinx-build -b html -n -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
+
+[testenv:docs-linkcheck]
+usedevelop = False
+deps = -rdocs/requirements.txt
+commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck