Allow skipping of normative type validation
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/3b236177 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3b236177 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3b236177 Branch: refs/heads/ARIA-1-parser-test-suite Commit: 3b236177dd37fde3b419832a0194226feab73e80 Parents: fa116d1 Author: Tal Liron <tal.li...@gmail.com> Authored: Tue Sep 26 17:58:57 2017 -0500 Committer: Tal Liron <tal.li...@gmail.com> Committed: Tue Sep 26 18:06:06 2017 -0500 ---------------------------------------------------------------------- aria/parser/consumption/presentation.py | 84 ++--- aria/parser/consumption/validation.py | 2 +- aria/parser/presentation/context.py | 3 + aria/parser/presentation/presentation.py | 2 + .../profiles/aria-1.0/aria-1.0.yaml | 3 + .../profiles/tosca-simple-1.0/artifacts.yaml | 8 + .../profiles/tosca-simple-1.0/capabilities.yaml | 12 + .../profiles/tosca-simple-1.0/data.yaml | 14 + .../profiles/tosca-simple-1.0/groups.yaml | 1 + .../profiles/tosca-simple-1.0/interfaces.yaml | 3 + .../profiles/tosca-simple-1.0/nodes.yaml | 14 + .../profiles/tosca-simple-1.0/policies.yaml | 5 + .../tosca-simple-1.0/relationships.yaml | 8 + .../tosca-simple-nfv-1.0/artifacts.yaml | 1 + .../tosca-simple-nfv-1.0/capabilities.yaml | 3 + .../profiles/tosca-simple-nfv-1.0/data.yaml | 10 + .../profiles/tosca-simple-nfv-1.0/nodes.yaml | 25 +- .../tosca-simple-nfv-1.0/relationships.yaml | 2 + .../simple_v1_0/assignments.py | 3 + .../aria_extension_tosca/simple_v1_0/data.py | 10 +- .../common/test_template_parameters.py | 145 +++----- .../common/test_template_properties.py | 125 +++++++ .../templates/common/test_templates.py | 17 +- .../templates/node_template/__init__.py | 14 + .../test_node_template_artifacts.py | 15 + .../test_node_template_capabilities.py | 15 + .../test_node_template_directives.py | 15 + .../test_node_template_node_filter.py | 18 + .../test_node_template_requirements.py | 15 + .../simple_v1_0/types/common/test_types.py | 32 +- .../simple_v1_0/types/node_type/__init__.py | 14 + .../types/node_type/test_node_type_artifacts.py | 77 ++++ .../node_type/test_node_type_capabilities.py | 306 ++++++++++++++++ .../test_node_type_relationship_interfaces.py | 92 +++++ .../node_type/test_node_type_requirements.py | 361 +++++++++++++++++++ .../simple_v1_0/types/node_types/__init__.py | 14 - .../node_types/test_node_type_artifacts.py | 77 ---- .../node_types/test_node_type_capabilities.py | 303 ---------------- .../test_node_type_relationship_interfaces.py | 92 ----- .../node_types/test_node_type_requirements.py | 361 ------------------- tests/mechanisms/parsing/aria.py | 1 + tests/topology/test_configuration.py | 4 +- 42 files changed, 1298 insertions(+), 1028 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/aria/parser/consumption/presentation.py ---------------------------------------------------------------------- diff --git a/aria/parser/consumption/presentation.py b/aria/parser/consumption/presentation.py index 62803bb..5f09c4d 100644 --- a/aria/parser/consumption/presentation.py +++ b/aria/parser/consumption/presentation.py @@ -45,15 +45,16 @@ class Read(Consumer): self._cache = {} def consume(self): - main, entries = self._present_all() + # Present the main location and all imports recursively + main, results = self._present_all() # Merge presentations - main.merge(entries, self.context) + main.merge(results, self.context) # Cache merged presentations if self.context.presentation.cache: - for presentation in entries: - presentation.cache() + for result in results: + result.cache() self.context.presentation.presenter = main.presentation if main.canonical_location is not None: @@ -80,25 +81,28 @@ class Read(Consumer): location = self.context.presentation.location if location is None: - self.context.validation.report('Presentation consumer: missing location') + self.context.validation.report('Read consumer: missing location') return executor = self.context.presentation.create_executor() try: + # This call may recursively submit tasks to the executor if there are imports main = self._present(location, None, None, executor) + + # Wait for all tasks to complete executor.drain() # Handle exceptions for e in executor.exceptions: self._handle_exception(e) - entries = executor.returns or [] + results = executor.returns or [] finally: executor.close() - entries.insert(0, main) + results.insert(0, main) - return main, entries + return main, results def _present(self, location, origin_canonical_location, origin_presenter_class, executor): # Link the context to this thread @@ -120,20 +124,19 @@ class Read(Consumer): # Is the presentation in the global cache? try: presentation = PRESENTATION_CACHE[canonical_location] - return _Entry(presentation, canonical_location, origin_canonical_location) + return _Result(presentation, canonical_location, origin_canonical_location) except KeyError: pass try: # Is the presentation in the local cache? presentation = self._cache[canonical_location] - return _Entry(presentation, canonical_location, origin_canonical_location) + return _Result(presentation, canonical_location, origin_canonical_location) except KeyError: pass # Create and cache new presentation - presentation = self._create_presentation(canonical_location, loader, - origin_presenter_class) + presentation = self._create_presentation(canonical_location, loader, origin_presenter_class) self._cache[canonical_location] = presentation # Submit imports to executor @@ -145,7 +148,7 @@ class Read(Consumer): executor.submit(self._present, import_location, canonical_location, presentation.__class__, executor) - return _Entry(presentation, canonical_location, origin_canonical_location) + return _Result(presentation, canonical_location, origin_canonical_location) def _create_loader(self, location, origin_canonical_location): loader = self.context.loading.loader_source.get_loader(self.context.loading, location, @@ -153,21 +156,21 @@ class Read(Consumer): canonical_location = None - # Because retrieving the canonical location can be costly, we will cache it - cache_key = None if origin_canonical_location is not None: cache_key = (origin_canonical_location, location) - - if cache_key is not None: try: canonical_location = CANONICAL_LOCATION_CACHE[cache_key] + return loader, canonical_location except KeyError: pass + else: + cache_key = None + + canonical_location = loader.get_canonical_location() - if canonical_location is None: - canonical_location = loader.get_canonical_location() - if cache_key is not None: - CANONICAL_LOCATION_CACHE[cache_key] = canonical_location + # Because retrieving the canonical location can be costly, we will try to cache it + if cache_key is not None: + CANONICAL_LOCATION_CACHE[cache_key] = canonical_location return loader, canonical_location @@ -206,51 +209,50 @@ class Read(Consumer): return presentation -class _Entry(object): +class _Result(object): def __init__(self, presentation, canonical_location, origin_canonical_location): self.presentation = presentation self.canonical_location = canonical_location self.origin_canonical_location = origin_canonical_location self.merged = False - def get_imports(self, entries): + def get_imports(self, results): imports = [] - def has_import(entry): + def has_import(result): for i in imports: - if i.canonical_location == entry.canonical_location: + if i.canonical_location == result.canonical_location: return True return False - for entry in entries: - if entry.origin_canonical_location == self.canonical_location: - if not has_import(entry): - imports.append(entry) + for result in results: + if result.origin_canonical_location == self.canonical_location: + if not has_import(result): + imports.append(result) return imports - def merge(self, entries, context): + def merge(self, results, context): # Make sure to only merge each presentation once if self.merged: return self.merged = True - for entry in entries: - if entry.presentation == self.presentation: - entry.merged = True + for result in results: + if result.presentation == self.presentation: + result.merged = True - for entry in self.get_imports(entries): + for result in self.get_imports(results): # Make sure import is merged - entry.merge(entries, context) + result.merge(results, context) # Validate import if hasattr(self.presentation, '_validate_import'): - # _validate_import will report an issue if invalid - valid = self.presentation._validate_import(context, entry.presentation) - else: - valid = True + if not self.presentation._validate_import(context, result.presentation): + # _validate_import will report an issue if invalid + continue # Merge import - if valid and hasattr(self.presentation, '_merge_import'): - self.presentation._merge_import(entry.presentation) + if hasattr(self.presentation, '_merge_import'): + self.presentation._merge_import(result.presentation) def cache(self): if not self.merged: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/aria/parser/consumption/validation.py ---------------------------------------------------------------------- diff --git a/aria/parser/consumption/validation.py b/aria/parser/consumption/validation.py index a7bc3b8..dd145ce 100644 --- a/aria/parser/consumption/validation.py +++ b/aria/parser/consumption/validation.py @@ -24,7 +24,7 @@ class Validate(Consumer): def consume(self): if self.context.presentation.presenter is None: - self.context.validation.report('Validation consumer: missing presenter') + self.context.validation.report('Validate consumer: missing presenter') return self.context.presentation.presenter._validate(self.context) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/aria/parser/presentation/context.py ---------------------------------------------------------------------- diff --git a/aria/parser/presentation/context.py b/aria/parser/presentation/context.py index 32e3fd6..c12d6fd 100644 --- a/aria/parser/presentation/context.py +++ b/aria/parser/presentation/context.py @@ -32,6 +32,8 @@ class PresentationContext(object): :vartype presenter_class: type :ivar import_profile: whether to import the profile by default (defaults to ``True``) :vartype import_profile: bool + :ivar validate_normative: whether to validate normative types (defaults to ``True``) + :vartype validate_normative: bool :ivar cache: whether to cache presentations (defaults to ``True``) :vartype cache: bool :ivar threads: number of threads to use when reading data (defaults to 8) @@ -48,6 +50,7 @@ class PresentationContext(object): self.presenter_source = DefaultPresenterSource() self.presenter_class = None # overrides self.import_profile = True + self.validate_normative = True self.cache = True self.threads = 8 # reasonable default for networking multithreading self.timeout = 10 # in seconds http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/aria/parser/presentation/presentation.py ---------------------------------------------------------------------- diff --git a/aria/parser/presentation/presentation.py b/aria/parser/presentation/presentation.py index 52c4255..988d6b3 100644 --- a/aria/parser/presentation/presentation.py +++ b/aria/parser/presentation/presentation.py @@ -199,6 +199,8 @@ class Presentation(PresentationBase): """ def _validate(self, context): + if (not context.presentation.validate_normative) and self._get_extension('normative'): + return validate_no_short_form(context, self) validate_no_unknown_fields(context, self) validate_known_fields(context, self) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml b/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml index e421150..82c456b 100644 --- a/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml +++ b/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml @@ -17,6 +17,7 @@ policy_types: aria.Plugin: _extensions: + normative: true shorthand_name: Plugin type_qualified_name: aria:Plugin role: plugin @@ -40,6 +41,7 @@ policy_types: aria.Workflow: _extensions: + normative: true shorthand_name: Workflow type_qualified_name: aria:Workflow role: workflow @@ -61,6 +63,7 @@ policy_types: aria.Scaling: _extensions: + normative: true type_qualified_name: aria:Scaling role: scaling description: >- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml index 945622f..963361f 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml @@ -17,6 +17,7 @@ artifact_types: tosca.artifacts.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -27,6 +28,7 @@ artifact_types: tosca.artifacts.File: _extensions: + normative: true shorthand_name: File type_qualified_name: tosca:File specification: tosca-simple-1.0 @@ -41,6 +43,7 @@ artifact_types: tosca.artifacts.Deployment: _extensions: + normative: true shorthand_name: Deployment # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Deployment specification: tosca-simple-1.0 @@ -54,6 +57,7 @@ artifact_types: tosca.artifacts.Deployment.Image: _extensions: + normative: true shorthand_name: Deployment.Image type_qualified_name: tosca:Deployment.Image specification: tosca-simple-1.0 @@ -67,6 +71,7 @@ artifact_types: tosca.artifacts.Deployment.Image.VM: _extensions: + normative: true shorthand_name: Deployment.VM # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Deployment.VM specification: tosca-simple-1.0 @@ -85,6 +90,7 @@ artifact_types: tosca.artifacts.Implementation: _extensions: + normative: true shorthand_name: Implementation # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Implementation specification: tosca-simple-1.0 @@ -97,6 +103,7 @@ artifact_types: tosca.artifacts.Implementation.Bash: _extensions: + normative: true shorthand_name: Implementation.Bash # ARIA NOTE: mistake in spec? shouldn't we have "Implementation." as prefix? type_qualified_name: tosca:Implementation.Bash specification: tosca-simple-1.0 @@ -109,6 +116,7 @@ artifact_types: tosca.artifacts.Implementation.Python: _extensions: + normative: true shorthand_name: Implementation.Python # ARIA NOTE: mistake in spec? shouldn't we have "Implementation." as prefix? type_qualified_name: tosca:Implementation.Python specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml index 66a4046..784279b 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml @@ -17,6 +17,7 @@ capability_types: tosca.capabilities.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -27,6 +28,7 @@ capability_types: tosca.capabilities.Node: _extensions: + normative: true shorthand_name: Node type_qualified_name: tosca:Node specification: tosca-simple-1.0 @@ -39,6 +41,7 @@ capability_types: tosca.capabilities.Container: _extensions: + normative: true shorthand_name: Container type_qualified_name: tosca:Container specification: tosca-simple-1.0 @@ -82,6 +85,7 @@ capability_types: tosca.capabilities.Attachment: _extensions: + normative: true shorthand_name: Attachment type_qualified_name: tosca:Attachment specification: tosca-simple-1.0 @@ -94,6 +98,7 @@ capability_types: tosca.capabilities.OperatingSystem: _extensions: + normative: true shorthand_name: OperatingSystem type_qualified_name: tosca:OperatingSystem specification: tosca-simple-1.0 @@ -127,6 +132,7 @@ capability_types: tosca.capabilities.Scalable: _extensions: + normative: true shorthand_name: Scalable type_qualified_name: tosca:Scalable specification: tosca-simple-1.0 @@ -163,6 +169,7 @@ capability_types: tosca.capabilities.Endpoint: _extensions: + normative: true shorthand_name: Endpoint type_qualified_name: tosca:Endpoint specification: tosca-simple-1.0 @@ -232,6 +239,7 @@ capability_types: tosca.capabilities.Endpoint.Public: _extensions: + normative: true shorthand_name: Endpoint.Public type_qualified_name: tosca:Endpoint.Public specification: tosca-simple-1.0 @@ -265,6 +273,7 @@ capability_types: tosca.capabilities.Endpoint.Admin: _extensions: + normative: true shorthand_name: Endpoint.Admin type_qualified_name: tosca:Endpoint.Admin specification: tosca-simple-1.0 @@ -284,6 +293,7 @@ capability_types: tosca.capabilities.Endpoint.Database: _extensions: + normative: true shorthand_name: Endpoint.Database type_qualified_name: tosca:Endpoint.Database specification: tosca-simple-1.0 @@ -299,6 +309,7 @@ capability_types: tosca.capabilities.network.Bindable: _extensions: + normative: true shorthand_name: Bindable # ARIA NOTE: mistake in spec? has "network." as a prefix type_qualified_name: tosca:Bindable specification: tosca-simple-1.0 @@ -311,6 +322,7 @@ capability_types: tosca.capabilities.network.Linkable: _extensions: + normative: true shorthand_name: Linkable type_qualified_name: tosca:Linkable specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml index 61d4186..7a65cbd 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml @@ -21,10 +21,12 @@ data_types: timestamp: _extensions: + normative: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_timestamp version: _extensions: + normative: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_version type_qualified_name: tosca:version specification: tosca-simple-1.0 @@ -33,6 +35,7 @@ data_types: range: _extensions: + normative: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_range type_qualified_name: tosca:range specification: tosca-simple-1.0 @@ -45,6 +48,7 @@ data_types: list: _extensions: + normative: true use_entry_schema: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_list type_qualified_name: tosca:list @@ -54,6 +58,7 @@ data_types: map: _extensions: + normative: true use_entry_schema: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_map_value type_qualified_name: tosca:map @@ -67,6 +72,7 @@ data_types: scalar-unit.size: _extensions: + normative: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_scalar_unit_size type_qualified_name: tosca:scalar-unit.size specification: tosca-simple-1.0 @@ -75,6 +81,7 @@ data_types: scalar-unit.time: _extensions: + normative: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_scalar_unit_time type_qualified_name: tosca:scalar-unit.time specification: tosca-simple-1.0 @@ -83,6 +90,7 @@ data_types: scalar-unit.frequency: _extensions: + normative: true coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_scalar_unit_frequency type_qualified_name: tosca:scalar-unit.frequency specification: tosca-simple-1.0 @@ -95,6 +103,7 @@ data_types: tosca.datatypes.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -105,6 +114,7 @@ data_types: tosca.datatypes.Credential: _extensions: + normative: true shorthand_name: Credential type_qualified_name: tosca:Credential specification: tosca-simple-1.0 @@ -145,6 +155,7 @@ data_types: tosca.datatypes.network.NetworkInfo: _extensions: + normative: true shorthand_name: NetworkInfo type_qualified_name: tosca:NetworkInfo specification: tosca-simple-1.0 @@ -174,6 +185,7 @@ data_types: tosca.datatypes.network.PortInfo: _extensions: + normative: true shorthand_name: PortInfo type_qualified_name: tosca:PortInfo specification: tosca-simple-1.0 @@ -213,6 +225,7 @@ data_types: tosca.datatypes.network.PortDef: _extensions: + normative: true shorthand_name: PortDef type_qualified_name: tosca:PortDef specification: tosca-simple-1.0 @@ -226,6 +239,7 @@ data_types: tosca.datatypes.network.PortSpec: _extensions: + normative: true shorthand_name: PortSpec type_qualified_name: tosca:PortSpec specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/groups.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/groups.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/groups.yaml index 66cc25f..9b9aa23 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/groups.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/groups.yaml @@ -17,6 +17,7 @@ group_types: tosca.groups.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml index 29cc8dd..25e8993 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml @@ -17,6 +17,7 @@ interface_types: tosca.interfaces.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -27,6 +28,7 @@ interface_types: tosca.interfaces.node.lifecycle.Standard: _extensions: + normative: true shorthand_name: Standard type_qualified_name: tosca:Standard specification: tosca-simple-1.0 @@ -52,6 +54,7 @@ interface_types: tosca.interfaces.relationship.Configure: _extensions: + normative: true shorthand_name: Configure type_qualified_name: tosca:Configure specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml index 05963b7..576b41b 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml @@ -17,6 +17,7 @@ node_types: tosca.nodes.Root: _extensions: + normative: true shorthand_name: Root type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -55,6 +56,7 @@ node_types: tosca.nodes.Compute: _extensions: + normative: true shorthand_name: Compute type_qualified_name: tosca:Compute specification: tosca-simple-1.0 @@ -106,6 +108,7 @@ node_types: tosca.nodes.LoadBalancer: _extensions: + normative: true shorthand_name: LoadBalancer type_qualified_name: tosca:LoadBalancer specification: tosca-simple-1.0 @@ -140,6 +143,7 @@ node_types: tosca.nodes.SoftwareComponent: _extensions: + normative: true shorthand_name: SoftwareComponent type_qualified_name: tosca:SoftwareComponent specification: tosca-simple-1.0 @@ -168,6 +172,7 @@ node_types: tosca.nodes.WebServer: _extensions: + normative: true shorthand_name: WebServer type_qualified_name: tosca:WebServer specification: tosca-simple-1.0 @@ -188,6 +193,7 @@ node_types: tosca.nodes.WebApplication: _extensions: + normative: true shorthand_name: WebApplication type_qualified_name: tosca:WebApplication specification: tosca-simple-1.0 @@ -214,6 +220,7 @@ node_types: tosca.nodes.DBMS: _extensions: + normative: true shorthand_name: DBMS # ARIA NOTE: omitted in the spec type_qualified_name: tosca:DBMS specification: tosca-simple-1.0 @@ -240,6 +247,7 @@ node_types: tosca.nodes.Database: _extensions: + normative: true shorthand_name: Database type_qualified_name: tosca:Database specification: tosca-simple-1.0 @@ -283,6 +291,7 @@ node_types: tosca.nodes.Container.Runtime: _extensions: + normative: true shorthand_name: Container.Runtime type_qualified_name: tosca:Container.Runtime specification: tosca-simple-1.0 @@ -300,6 +309,7 @@ node_types: tosca.nodes.Container.Application: _extensions: + normative: true shorthand_name: Container.Application type_qualified_name: tosca:Container.Application specification: tosca-simple-1.0 @@ -321,6 +331,7 @@ node_types: tosca.nodes.ObjectStorage: _extensions: + normative: true shorthand_name: ObjectStorage type_qualified_name: tosca:ObjectStorage specification: tosca-simple-1.0 @@ -354,6 +365,7 @@ node_types: tosca.nodes.BlockStorage: _extensions: + normative: true shorthand_name: BlockStorage type_qualified_name: tosca:BlockStorage specification: tosca-simple-1.0 @@ -388,6 +400,7 @@ node_types: tosca.nodes.network.Network: _extensions: + normative: true shorthand_name: Network type_qualified_name: tosca:Network specification: tosca-simple-1.0 @@ -466,6 +479,7 @@ node_types: tosca.nodes.network.Port: _extensions: + normative: true shorthand_name: Port type_qualified_name: tosca:Port specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml index 7b35bb9..2ff672e 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml @@ -17,6 +17,7 @@ policy_types: tosca.policies.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -27,6 +28,7 @@ policy_types: tosca.policies.Placement: _extensions: + normative: true shorthand_name: Placement # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Placement specification: tosca-simple-1.0 @@ -38,6 +40,7 @@ policy_types: tosca.policies.Scaling: _extensions: + normative: true shorthand_name: Scaling # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Scaling specification: tosca-simple-1.0 @@ -49,6 +52,7 @@ policy_types: tosca.policies.Update: _extensions: + normative: true shorthand_name: Update # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Update specification: tosca-simple-1.0 @@ -60,6 +64,7 @@ policy_types: tosca.policies.Performance: _extensions: + normative: true shorthand_name: Performance # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Performance specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml index 9f2c32c..b45da96 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml @@ -17,6 +17,7 @@ relationship_types: tosca.relationships.Root: _extensions: + normative: true shorthand_name: Root # ARIA NOTE: omitted in the spec type_qualified_name: tosca:Root specification: tosca-simple-1.0 @@ -46,6 +47,7 @@ relationship_types: tosca.relationships.DependsOn: _extensions: + normative: true shorthand_name: DependsOn type_qualified_name: tosca:DependsOn specification: tosca-simple-1.0 @@ -58,6 +60,7 @@ relationship_types: tosca.relationships.HostedOn: _extensions: + normative: true shorthand_name: HostedOn type_qualified_name: tosca:HostedOn specification: tosca-simple-1.0 @@ -70,6 +73,7 @@ relationship_types: tosca.relationships.ConnectsTo: _extensions: + normative: true shorthand_name: ConnectsTo type_qualified_name: tosca:ConnectsTo specification: tosca-simple-1.0 @@ -86,6 +90,7 @@ relationship_types: tosca.relationships.AttachesTo: _extensions: + normative: true shorthand_name: AttachesTo type_qualified_name: tosca:AttachesTo specification: tosca-simple-1.0 @@ -119,6 +124,7 @@ relationship_types: tosca.relationships.RoutesTo: _extensions: + normative: true shorthand_name: RoutesTo type_qualified_name: tosca:RoutesTo specification: tosca-simple-1.0 @@ -135,6 +141,7 @@ relationship_types: tosca.relationships.network.LinksTo: _extensions: + normative: true shorthand_name: LinksTo type_qualified_name: tosca:LinksTo specification: tosca-simple-1.0 @@ -147,6 +154,7 @@ relationship_types: tosca.relationships.network.BindsTo: _extensions: + normative: true shorthand_name: BindsTo # ARIA NOTE: the spec says "network.BindsTo" which seems wrong type_qualified_name: tosca:BindsTo specification: tosca-simple-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/artifacts.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/artifacts.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/artifacts.yaml index 2427d9f..4a8e3c6 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/artifacts.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/artifacts.yaml @@ -17,6 +17,7 @@ artifact_types: tosca.artifacts.nfv.SwImage: _extensions: + normative: true shorthand_name: SwImage type_qualified_name: tosca:SwImage specification: tosca-simple-nfv-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/capabilities.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/capabilities.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/capabilities.yaml index 7b6363f..0e71a3b 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/capabilities.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/capabilities.yaml @@ -17,6 +17,7 @@ capability_types: tosca.capabilities.nfv.VirtualBindable: _extensions: + normative: true shorthand_name: VirtualBindable type_qualified_name: tosca:VirtualBindable specification: tosca-simple-nfv-1.0 @@ -29,6 +30,7 @@ capability_types: tosca.capabilities.nfv.Metric: _extensions: + normative: true shorthand_name: Metric type_qualified_name: tosca:Metric specification: tosca-simple-nfv-1.0 @@ -41,6 +43,7 @@ capability_types: tosca.capabilities.nfv.VirtualCompute: _extensions: + normative: true shorthand_name: VirtualCompute type_qualified_name: tosca:VirtualCompute specification: tosca-simple-nfv-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml index 889dcf7..09f173d 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/data.yaml @@ -18,6 +18,7 @@ data_types: tosca.datatypes.nfv.L2AddressData: # TBD _extensions: + normative: true shorthand_name: L2AddressData type_qualified_name: tosca:L2AddressData specification: tosca-simple-nfv-1.0 @@ -26,6 +27,7 @@ data_types: tosca.datatypes.nfv.L3AddressData: _extensions: + normative: true shorthand_name: L3AddressData type_qualified_name: tosca:L3AddressData specification: tosca-simple-nfv-1.0 @@ -65,6 +67,7 @@ data_types: tosca.datatypes.nfv.AddressData: _extensions: + normative: true shorthand_name: AddressData type_qualified_name: tosca:AddressData specification: tosca-simple-nfv-1.0 @@ -102,6 +105,7 @@ data_types: tosca.datatypes.nfv.VirtualNetworkInterfaceRequirements: _extensions: + normative: true shorthand_name: VirtualNetworkInterfaceRequirements type_qualified_name: tosca:VirtualNetworkInterfaceRequirements specification: tosca-simple-nfv-1.0 @@ -139,6 +143,7 @@ data_types: tosca.datatypes.nfv.ConnectivityType: _extensions: + normative: true shorthand_name: ConnectivityType type_qualified_name: tosca:ConnectivityType specification: tosca-simple-nfv-1.0 @@ -165,6 +170,7 @@ data_types: tosca.datatypes.nfv.RequestedAdditionalCapability: _extensions: + normative: true shorthand_name: RequestedAdditionalCapability type_qualified_name: tosca:RequestedAdditionalCapability specification: tosca-simple-nfv-1.0 @@ -205,6 +211,7 @@ data_types: tosca.datatypes.nfv.VirtualMemory: _extensions: + normative: true shorthand_name: VirtualMemory type_qualified_name: tosca:VirtualMemory specification: tosca-simple-nfv-1.0 @@ -235,6 +242,7 @@ data_types: tosca.datatypes.nfv.VirtualCpu: _extensions: + normative: true shorthand_name: VirtualCpu type_qualified_name: tosca:VirtualCpu specification: tosca-simple-nfv-1.0 @@ -272,6 +280,7 @@ data_types: tosca.datatypes.nfv.VirtualCpuPinning: _extensions: + normative: true shorthand_name: VirtualCpuPinning type_qualified_name: tosca:VirtualCpuPinning specification: tosca-simple-nfv-1.0 @@ -299,6 +308,7 @@ data_types: tosca.datatypes.nfv.VnfcConfigurableProperties: _extensions: + normative: true shorthand_name: VnfcconfigurableProperties type_qualified_name: tosca:VnfcconfigurableProperties specification: tosca-simple-nfv-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml index 8d1f0a2..4d7f337 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml @@ -17,6 +17,7 @@ node_types: tosca.nodes.nfv.VDU.Compute: _extensions: + normative: true shorthand_name: VDU.Compute type_qualified_name: tosca:VDU.Compute specification: tosca-simple-nfv-1.0 @@ -115,6 +116,7 @@ node_types: tosca.nodes.nfv.VDU.VirtualStorage: _extensions: + normative: true shorthand_name: VirtualStorage # ARIA NOTE: seems wrong in spec type_qualified_name: tosca:VirtualStorage # ARIA NOTE: seems wrong in spec specification: tosca-simple-nfv-1.0 @@ -151,6 +153,7 @@ node_types: tosca.nodes.nfv.Cpd: _extensions: + normative: true shorthand_name: Cpd type_qualified_name: tosca:Cpd specification: tosca-simple-nfv-1.0 @@ -194,11 +197,12 @@ node_types: tosca.nodes.nfv.VduCpd: _extensions: - shorthand_name: VduCpd - type_qualified_name: tosca:VduCpd - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.5 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896082' + normative: true + shorthand_name: VduCpd + type_qualified_name: tosca:VduCpd + specification: tosca-simple-nfv-1.0 + specification_section: 5.9.5 + specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896082' description: >- The TOSCA nfv.VduCpd node type represents a type of TOSCA Cpd node and describes network connectivity between a VNFC instance (based on this VDU) and an internal VL as defined by @@ -232,11 +236,12 @@ node_types: tosca.nodes.nfv.VnfVirtualLinkDesc: _extensions: - shorthand_name: VnfVirtualLinkDesc - type_qualified_name: tosca:VnfVirtualLinkDesc - specification: tosca-simple-nfv-1.0 - specification_section: 5.9.6 - specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896083' + normative: true + shorthand_name: VnfVirtualLinkDesc + type_qualified_name: tosca:VnfVirtualLinkDesc + specification: tosca-simple-nfv-1.0 + specification_section: 5.9.6 + specification_url: 'http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/csd04/tosca-nfv-v1.0-csd04.html#_Toc482896083' description: >- The TOSCA nfv.VnfVirtualLinkDesc node type represents a logical internal virtual link as defined by [ETSI GS NFV-IFA 011]. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml index 4cf99a2..84c6a87 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/relationships.yaml @@ -17,6 +17,7 @@ relationship_types: tosca.relationships.nfv.VirtualBindsTo: _extensions: + normative: true shorthand_name: VirtualBindsTo type_qualified_name: tosca:VirtualBindsTo specification: tosca-simple-nfv-1.0 @@ -31,6 +32,7 @@ relationship_types: # valid_target_types), so we are using the definition in csd03 section 8.4.2. tosca.relationships.nfv.Monitor: _extensions: + normative: true shorthand_name: Monitor type_qualified_name: tosca:Monitor specification: tosca-simple-nfv-1.0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/extensions/aria_extension_tosca/simple_v1_0/assignments.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/assignments.py b/extensions/aria_extension_tosca/simple_v1_0/assignments.py index 6af994b..55b7e8d 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/assignments.py +++ b/extensions/aria_extension_tosca/simple_v1_0/assignments.py @@ -391,6 +391,9 @@ class ArtifactAssignmentForType(ExtensiblePresentation): Template and used by orchestration engine to facilitate deployment and implementation of interface operations. + ARIA NOTE: section 3.5.6.2.1 in the spec refers to a short notation for "file", but that + notation would be impossible because the "type" field is required. + See the `TOSCA Simple Profile v1.0 cos01 specification <http://docs.oasis-open.org/tosca /TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html #DEFN_ENTITY_ARTIFACT_DEF>`__ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/data.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py index 46d64d7..dff3d2d 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py @@ -17,9 +17,6 @@ # Keywords -TYPE_NAMES_NO_UNSUPPORTED_FIELDS = ('artifact', 'data', 'capability', 'relationship', 'node', - 'group', 'policy') -TYPE_NAMES = TYPE_NAMES_NO_UNSUPPORTED_FIELDS + ('interface',) TYPE_NAME_PLURAL = { 'artifact': 'artifacts', 'data': 'datatypes', @@ -30,20 +27,20 @@ TYPE_NAME_PLURAL = { 'group': 'groups', 'policy': 'policies' } -PRIMITIVE_TYPE_NAMES = ('string', 'integer', 'float', 'boolean') -PARAMETER_SECTION_NAMES = ('properties', 'attributes') -TEMPLATE_NAMES = ('node', 'group', 'relationship', 'policy') TEMPLATE_NAME_SECTIONS = { 'node': 'node_templates', 'group': 'groups', 'relationship': 'relationship_templates', 'policy': 'policies' } +PRIMITIVE_TYPE_NAMES = ('string', 'integer', 'float', 'boolean') +PARAMETER_TYPE_NAMES = PRIMITIVE_TYPE_NAMES + ('MyType',) CONSTRAINTS_WITH_VALUE = ('equal', 'greater_than', 'greater_or_equal', 'less_than', 'less_or_equal') CONSTRAINTS_WITH_VALUE_LIST = ('valid_values',) CONSTRAINTS_WITH_VALUE_RANGE = ('in_range',) CONSTRAINTS_WITH_NON_NEGATIVE_INT = ('length', 'min_length', 'max_length') + # Values NOT_A_DICT = ('null', 'true', 'a string', '123', '0.123', '[]') @@ -62,7 +59,6 @@ BAD_OCCURRENCES = NOT_A_RANGE + ('[ -1, 1 ]', '[ 0, unbounded ]') GOOD_VERSIONS = ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'") BAD_VERSIONS = ('a_string', '1.2.3.4.5', '1.2.beta', '1.0.0.alpha-x') STATUSES = ('supported', 'unsupported', 'experimental', 'deprecated') -PARAMETER_TYPE_NAMES = PRIMITIVE_TYPE_NAMES + ('MyType',) PARAMETER_VALUES = ( ('string', 'a string'), ('integer', '1'), http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py index 76581bf..25cbfa0 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py @@ -31,6 +31,41 @@ MAIN_MACROS = """ {%- endmacro %} """ +CAPABILITY_MACROS = """ +{% macro additions() %} +{%- endmacro %} +{% macro type_parameters() %} + capabilities: + my_capability: + type: MyType +capability_types: + MyType: + {{ parameter_section }}: {{ caller()|indent(6) }} +{%- endmacro %} +{% macro parameters() %} + capabilities: + my_capability: + {{ parameter_section }}: {{ caller()|indent(12) }} +{%- endmacro %} +""" + +ARTIFACT_MACROS = """ +{% macro additions() %} +{%- endmacro %} +{% macro type_parameters() %} {} +artifact_types: + MyType: + {{ parameter_section }}: {{ caller()|indent(6) }} +{%- endmacro %} +{% macro parameters() %} + artifacts: + my_artifact: + type: MyType + file: a file + {{ parameter_section }}: {{ caller()|indent(12) }} +{%- endmacro %} +""" + INTERFACE_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -49,7 +84,6 @@ interface_types: {%- endmacro %} """ - OPERATION_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -108,7 +142,6 @@ interface_types: {%- endmacro %} """ - RELATIONSHIP_TYPE_MACROS = """ {% macro additions() %} capability_types: @@ -134,7 +167,6 @@ relationship_types: {%- endmacro %} """ - RELATIONSHIP_LOCAL_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -227,7 +259,6 @@ interface_types: {%- endmacro %} """ - RELATIONSHIP_TYPE_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -290,7 +321,6 @@ relationship_types: {%- endmacro %} """ - RELATIONSHIP_LOCAL_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -355,6 +385,8 @@ interface_types: MACROS = { 'main': MAIN_MACROS, + 'capability': CAPABILITY_MACROS, + 'artifact': ARTIFACT_MACROS, 'interface': INTERFACE_MACROS, 'operation': OPERATION_MACROS, 'local-interface': LOCAL_INTERFACE_MACROS, @@ -375,6 +407,9 @@ PARAMETER_SECTIONS = ( ('main', 'relationship', 'properties'), ('main', 'relationship', 'attributes'), ('main', 'policy', 'properties'), + ('capability', 'node', 'properties'), + ('capability', 'node', 'attributes'), + ('artifact', 'node', 'properties'), ('interface', 'node', 'inputs'), ('interface', 'group', 'inputs'), ('interface', 'relationship', 'inputs'), @@ -396,13 +431,6 @@ PARAMETER_SECTIONS = ( #('relationship-operation', 'node', 'inputs'), # fix ) -PROPERTY_SECTIONS = ( - ('main', 'node'), - ('main', 'group'), - ('main', 'relationship'), - ('main', 'policy') -) - # Parameters section @@ -454,6 +482,7 @@ topology_template: # Parameter +@pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS) def test_template_parameter_missing(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ @@ -475,94 +504,6 @@ my_parameter: a value parameter_section=parameter_section)).assert_failure() -# Required (properties only) - -@pytest.mark.parametrize('macros,name,type_name', matrix( - PROPERTY_SECTIONS, - data.PARAMETER_TYPE_NAMES, - counts=(2, 1) -)) -def test_template_property_required(parser, macros, name, type_name): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyType: - properties: - my_field: - type: string -{{ name }}_types: - MyType: -{%- call type_parameters() %} -my_property: - type: {{ type_name }} -{% endcall %} -topology_template: - {{ section }}: - my_template: - type: MyType -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', - type_name=type_name)).assert_failure() - - -@pytest.mark.parametrize('macros,name,type_name', matrix( - PROPERTY_SECTIONS, - data.PARAMETER_TYPE_NAMES, - counts=(2, 1) -)) -def test_template_property_not_required(parser, macros, name, type_name): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyType: - properties: - my_field: - type: string -{{ name }}_types: - MyType: -{%- call type_parameters() %} -my_property: - type: {{ type_name }} - required: false -{% endcall %} -topology_template: - {{ section }}: - my_template: - type: MyType -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', - type_name=type_name)).assert_success() - - -@pytest.mark.parametrize('macros,name,type_name,value', matrix( - PROPERTY_SECTIONS, - data.PARAMETER_VALUES, - counts=(2, 2) -)) -def test_template_property_required_with_default(parser, macros, name, type_name, value): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyType: - properties: - my_field: - type: string -{{ name }}_types: - MyType: -{%- call type_parameters() %} -my_property: - type: {{ type_name }} - default: {{ value }} -{% endcall %} -topology_template: - {{ section }}: - my_template: - type: MyType -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', - type_name=type_name, value=value)).assert_success() - - # Entry schema @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( @@ -600,6 +541,7 @@ my_parameter: values=values), import_profile=True).assert_success() +@pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( PARAMETER_SECTIONS, data.ENTRY_SCHEMA_VALUES_BAD, @@ -664,6 +606,7 @@ my_parameter: parameter_section=parameter_section), import_profile=True).assert_success() +@pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS) def test_template_parameter_map_required_field_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ @@ -728,6 +671,7 @@ my_parameter: values=values), import_profile=True).assert_success() +@pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( PARAMETER_SECTIONS, data.ENTRY_SCHEMA_VALUES_BAD, @@ -792,6 +736,7 @@ my_parameter: parameter_section=parameter_section), import_profile=True).assert_success() +@pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS) def test_template_parameter_list_required_field_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py new file mode 100644 index 0000000..105ec98 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from .test_template_parameters import (MACROS, PARAMETER_SECTIONS) +from ... import data +from ......mechanisms.utils import matrix + + +PROPERTY_SECTIONS = tuple( + (macros, name) for macros, name, type_name in PARAMETER_SECTIONS if type_name == 'properties' +) + + + +# Required + +@pytest.mark.skip(reason='fix for relationships') +@pytest.mark.parametrize('macros,name,type_name', matrix( + PROPERTY_SECTIONS, + data.PARAMETER_TYPE_NAMES, + counts=(2, 1) +)) +def test_template_property_required(parser, macros, name, type_name): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +data_types: + MyType: + properties: + my_field: + type: string +{{ name }}_types: + MyType: +{%- call type_parameters() %} +my_property: + type: {{ type_name }} +{% endcall %} +topology_template: + {{ section }}: + my_template: + type: MyType +{%- call parameters() -%} +{} +{% endcall %} +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', + type_name=type_name)).assert_failure() + + +@pytest.mark.parametrize('macros,name,type_name', matrix( + PROPERTY_SECTIONS, + data.PARAMETER_TYPE_NAMES, + counts=(2, 1) +)) +def test_template_property_not_required(parser, macros, name, type_name): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +data_types: + MyType: + properties: + my_field: + type: string +{{ name }}_types: + MyType: +{%- call type_parameters() %} +my_property: + type: {{ type_name }} + required: false +{% endcall %} +topology_template: + {{ section }}: + my_template: + type: MyType +{%- call parameters() -%} +{} +{% endcall %} +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', + type_name=type_name)).assert_success() + + +@pytest.mark.parametrize('macros,name,type_name,value', matrix( + PROPERTY_SECTIONS, + data.PARAMETER_VALUES, + counts=(2, 2) +)) +def test_template_property_required_with_default(parser, macros, name, type_name, value): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +data_types: + MyType: + properties: + my_field: + type: string +{{ name }}_types: + MyType: +{%- call type_parameters() %} +my_property: + type: {{ type_name }} + default: {{ value }} +{% endcall %} +topology_template: + {{ section }}: + my_template: + type: MyType +{%- call parameters() -%} +{} +{% endcall %} +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', + type_name=type_name, value=value)).assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py index 7d1ac3d..ed6d553 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py @@ -20,10 +20,13 @@ from ... import data from ......mechanisms.utils import matrix +TEMPLATE_NAMES = ('node', 'group', 'relationship', 'policy') + + # Templates section @pytest.mark.parametrize('name,value', matrix( - data.TEMPLATE_NAMES, + TEMPLATE_NAMES, data.NOT_A_DICT )) def test_templates_section_syntax_type(parser, name, value): @@ -34,7 +37,7 @@ topology_template: """, dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() -@pytest.mark.parametrize('name', data.TEMPLATE_NAMES) +@pytest.mark.parametrize('name', TEMPLATE_NAMES) def test_templates_section_syntax_empty(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -45,7 +48,7 @@ topology_template: # Template -@pytest.mark.parametrize('name', data.TEMPLATE_NAMES) +@pytest.mark.parametrize('name', TEMPLATE_NAMES) def test_template_syntax_unsupported(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -59,7 +62,7 @@ topology_template: # Description @pytest.mark.parametrize('name,value', matrix( - data.TEMPLATE_NAMES, + TEMPLATE_NAMES, data.NOT_A_STRING )) def test_template_description_syntax_type(parser, name, value): @@ -75,7 +78,7 @@ topology_template: # Type @pytest.mark.parametrize('name,value', matrix( - data.TEMPLATE_NAMES, + TEMPLATE_NAMES, data.NOT_A_STRING )) def test_template_type_syntax_type(parser, name, value): @@ -87,7 +90,7 @@ topology_template: type: {{ value }} """, dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() -@pytest.mark.parametrize('name', data.TEMPLATE_NAMES) +@pytest.mark.parametrize('name', TEMPLATE_NAMES) def test_template_type_unknown(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -100,7 +103,7 @@ topology_template: # Unicode -@pytest.mark.parametrize('name', data.TEMPLATE_NAMES) +@pytest.mark.parametrize('name', TEMPLATE_NAMES) def test_template_unicode(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/__init__.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/__init__.py new file mode 100644 index 0000000..ae1e83e --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/__init__.py @@ -0,0 +1,14 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py new file mode 100644 index 0000000..8ca2ef7 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py new file mode 100644 index 0000000..8ca2ef7 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py new file mode 100644 index 0000000..8ca2ef7 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py new file mode 100644 index 0000000..7fe2609 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# TODO: both general and in requirements http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py new file mode 100644 index 0000000..8ca2ef7 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py index 1e48b9a..efa91c5 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py @@ -20,8 +20,14 @@ from ... import data from ......mechanisms.utils import matrix +TYPE_NAMES_NO_UNSUPPORTED_FIELDS = ('artifact', 'data', 'capability', 'relationship', 'node', + 'group', 'policy') + +TYPE_NAMES = TYPE_NAMES_NO_UNSUPPORTED_FIELDS + ('interface',) + + @pytest.mark.parametrize('name,value', matrix( - data.TYPE_NAMES, + TYPE_NAMES, data.NOT_A_DICT )) def test_type_syntax_type(parser, name, value): @@ -32,7 +38,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name, value=value)).assert_failure() -@pytest.mark.parametrize('name', data.TYPE_NAMES_NO_UNSUPPORTED_FIELDS) +@pytest.mark.parametrize('name', TYPE_NAMES_NO_UNSUPPORTED_FIELDS) def test_type_syntax_unsupported(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -42,7 +48,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name)).assert_failure() -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_syntax_empty(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -54,7 +60,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Description @pytest.mark.parametrize('name,value', matrix( - data.TYPE_NAMES, + TYPE_NAMES, data.NOT_A_STRING )) def test_type_description_syntax_type(parser, name, value): @@ -66,7 +72,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name, value=value)).assert_failure() -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_description(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -79,7 +85,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Derived from @pytest.mark.parametrize('name,value', matrix( - data.TYPE_NAMES, + TYPE_NAMES, data.NOT_A_STRING )) def test_type_derived_from_syntax_type(parser, name, value): @@ -91,7 +97,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name, value=value)).assert_failure() -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_derived_from(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -102,7 +108,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name)).assert_success() -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_derived_from_unknown(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -112,7 +118,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name)).assert_failure() -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_derived_from_self(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -122,7 +128,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name)).assert_failure() -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_derived_from_circular(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -139,7 +145,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Version @pytest.mark.parametrize('name,value', matrix( - data.TYPE_NAMES, + TYPE_NAMES, data.GOOD_VERSIONS )) def test_type_version(parser, name, value): @@ -152,7 +158,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 @pytest.mark.parametrize('name,value', matrix( - data.TYPE_NAMES, + TYPE_NAMES, data.BAD_VERSIONS )) def test_type_version_bad(parser, name, value): @@ -166,7 +172,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Unicode -@pytest.mark.parametrize('name', data.TYPE_NAMES) +@pytest.mark.parametrize('name', TYPE_NAMES) def test_type_unicode(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py new file mode 100644 index 0000000..ae1e83e --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py @@ -0,0 +1,14 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_artifacts.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_artifacts.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_artifacts.py new file mode 100644 index 0000000..0c28d5a --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_artifacts.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from ... import data + + +# Artifacts section + +@pytest.mark.parametrize('value', data.NOT_A_DICT) +def test_node_type_artifacts_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_artifacts_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: {} +""").assert_success() + + +# Artifact + +@pytest.mark.parametrize('value', data.NOT_A_DICT) +def test_node_type_artifact_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: + my_artifact: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_artifact_syntax_unsupported(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +artifact_types: + MyType: {} +node_types: + MyType: + artifacts: + my_artifact: + type: MyType + unsupported: {} +""").assert_failure() + + +def test_node_type_artifact_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: + my_artifact: {} # "type" is required +""").assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3b236177/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py new file mode 100644 index 0000000..1a60b54 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py @@ -0,0 +1,306 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from ... import data + + +PARAMETER_SECTION_NAMES = ('properties', 'attributes') + + +# Capabilities section + +@pytest.mark.parametrize('value', data.NOT_A_DICT) +def test_node_type_capabilities_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_capabilities_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: {} +""").assert_success() + + +# Capability + +@pytest.mark.parametrize('value', data.NOT_A_DICT) +def test_node_type_capability_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: + my_capability: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_capability_syntax_unsupported(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + unsupported: {} +""").assert_failure() + + +def test_node_type_capability_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: + my_capability: {} # "type" is required +""").assert_failure() + + +# Description + +@pytest.mark.parametrize('value', data.NOT_A_STRING) +def test_node_type_capability_description_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + description: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_capability_description(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + description: a description +""").assert_success() + + +# Type + +@pytest.mark.parametrize('value', data.NOT_A_STRING) +def test_node_type_capability_type_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: + my_capability: + type: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_capability_type_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: + my_capability: + type: UnknownType +""").assert_failure() + + +def test_node_type_capability_type_override(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: + derived_from: MyType1 +node_types: + MyType1: + capabilities: + my_capability: + type: MyType1 + MyType2: + derived_from: MyType1 + capabilities: + my_capability: + type: MyType2 +""").assert_success() + + +def test_node_type_capability_type_override_bad(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: + derived_from: MyType1 +node_types: + MyType1: + capabilities: + my_capability: + type: MyType2 + MyType2: + derived_from: MyType1 + capabilities: + my_capability: + type: MyType1 +""").assert_failure() + + +# Valid source types + +@pytest.mark.parametrize('value', data.NOT_A_LIST) +def test_node_type_capability_valid_source_types_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + valid_source_types: {{ value }} +""", dict(value=value)).assert_failure() + + +@pytest.mark.parametrize('value', data.NOT_A_STRING) +def test_node_type_capability_valid_source_types_syntax_element_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + valid_source_types: [ {{ value }} ] +""", dict(value=value)).assert_failure() + + +def test_node_type_capability_valid_source_types_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + valid_source_types: [] +""").assert_success() + + + +def test_node_type_capability_valid_source_types(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType1: + capabilities: + my_capability: + type: MyType + valid_source_types: [ MyType1, MyType2 ] + MyType2: {} +""").assert_success() + + +def test_node_type_capability_valid_source_types_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + valid_source_types: [ UnknownType ] +""").assert_failure() + + +# Occurrences + +@pytest.mark.parametrize('value', data.OCCURRENCES) +def test_node_type_capability_occurrences(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + occurrences: {{ value }} +""", dict(value=value)).assert_success() + + +@pytest.mark.parametrize('value', data.BAD_OCCURRENCES) +def test_node_type_capability_occurrences_bad(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: + type: MyType + occurrences: {{ value }} +""", dict(value=value)).assert_failure() + + +# Unicode + +def test_node_type_capability_unicode(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + é¡å: {} +node_types: + é¡å: + capabilities: + è½å: + type: é¡å + properties: + åæ¸: + type: string + description: æè¿° + default: å¼ + status: supported + valid_source_types: [ é¡å ] +""").assert_success()