ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject [06/10] incubator-ariatosca git commit: Fix examples, more tests for interfaces and parameters
Date Wed, 30 Aug 2017 22:13:22 GMT
Fix examples, more tests for interfaces and parameters


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8c05149f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8c05149f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8c05149f

Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 8c05149f1c6bfa69f73000d95f762331cd3f1887
Parents: deb02b2
Author: Tal Liron <tal.liron@gmail.com>
Authored: Mon Aug 28 16:14:37 2017 -0500
Committer: Tal Liron <tal.liron@gmail.com>
Committed: Wed Aug 30 10:40:50 2017 -0500

----------------------------------------------------------------------
 .travis.yml                                     |   2 +
 .../use-cases/non-normative-types.yaml          |   1 +
 .../types/test_node_type_interfaces.py          |  72 ----
 .../simple_v1_0/types/test_type_interfaces.py   | 410 +++++++++++++++++++
 .../simple_v1_0/types/test_type_parameters.py   |  18 +-
 5 files changed, 430 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index c423114..4aafd5b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,8 @@
 
 sudo: false
 
+# TODO: The default dist is "trusty", but it is broken for us because it doesn't have Python
2.6,
+# and does not allow SSH access (for py2?ssh tests)
 dist: precise
 
 language: python

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml b/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
index 24f22a3..6e63ca1 100644
--- a/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
+++ b/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
@@ -161,6 +161,7 @@ node_types:
         default: https://github.com/mmm/testnode.git
     interfaces:
       Standard:
+        type: tosca.interfaces.node.lifecycle.Standard # ARIA NOTE: missing in spec
         inputs:
           github_url:
             type: string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
deleted file mode 100644
index 0228c02..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# -*- 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
-
-
-# Overriding
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_interface_override_change_type_good(parser):
-    parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
-  MyType1:
-    inputs:
-      input1:
-        type: string
-  MyType2:
-    derived_from: MyType1
-    inputs:
-      input2:
-        type: integer
-node_types:
-  MyType1:
-    interfaces:
-      my_interface:
-        type: MyType1
-  MyType2:
-    derived_from: MyType1
-    interfaces:
-      my_interface:
-        type: MyType2
-""").assert_success()
-
-
-def test_node_type_interface_override_change_type_bad(parser):
-    parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
-  MyType1:
-    inputs:
-      input1:
-        type: string
-  MyType2:
-    derived_from: MyType1
-    inputs:
-      input2:
-        type: integer
-node_types:
-  MyType1:
-    interfaces:
-      my_interface:
-        type: MyType2
-  MyType2:
-    derived_from: MyType1
-    interfaces:
-      my_interface:
-        type: MyType1
-""").assert_failure()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
new file mode 100644
index 0000000..4b47a0b
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
@@ -0,0 +1,410 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+TYPE_NAMES = ('node', 'relationship', 'group')
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+    TYPE_NAMES,
+    data.NOT_A_DICT
+))
+def test_type_interface_wrong_yaml_type(parser, name, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_empty(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface: {} # "type" is required
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        inputs: {}
+        operation1: {}
+        operation2: {}
+""", dict(name=name)).assert_success()
+
+
+# Type
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_override_type_good(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType1: {}
+  MyType2: {}
+{{ name }}_types:
+  MyType1:
+    interfaces:
+      my_interface:
+        type: MyType1
+  MyType2:
+    derived_from: MyType1
+    interfaces:
+      my_interface:
+        type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_override_type_bad(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType1: {}
+  MyType2: {}
+{{ name }}_types:
+  MyType1:
+    interfaces:
+      my_interface:
+        type: MyType2
+  MyType2:
+    derived_from: MyType1
+    interfaces:
+      my_interface:
+        type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Interface inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_add(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: string
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        inputs:
+          my_input2:
+            type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_override_same_type(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: string
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        inputs:
+          my_input1:
+            type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_override_derived_type(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+  MyType1: {}
+  MyType2: {}
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: MyType1
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        inputs:
+          my_input1:
+            type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_override_bad(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+  MyType1: {}
+  MyType2: {}
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: MyType2
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        inputs:
+          my_input1:
+            type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Operations
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_empty(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_fields(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          description: a description
+          implementation: {}
+          inputs: {}
+""", dict(name=name)).assert_success()
+
+
+# Operation implementation
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_short_form(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          implementation: an implementation
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_long_form(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          implementation:
+            primary: an implementation
+            dependencies:
+              - a dependency
+              - another dependency
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+    TYPE_NAMES,
+    data.NOT_A_STRING
+))
+def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          implementation:
+            primary: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+    TYPE_NAMES,
+    data.NOT_A_STRING
+))
+def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType: {}
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          implementation:
+            primary: an implementation
+            dependencies:
+              - {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Operation inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_add(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: string
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          inputs:
+            my_input2:
+              type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_same_type(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: string
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          inputs:
+            my_input1:
+              type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_derived_type(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+  MyType1: {}
+  MyType2: {}
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: MyType1
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          inputs:
+            my_input1:
+              type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_bad(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+  MyType1: {}
+  MyType2: {}
+interface_types:
+  MyType:
+    inputs:
+      my_input1:
+        type: MyType2
+{{ name }}_types:
+  MyType:
+    interfaces:
+      my_interface:
+        type: MyType
+        operation1:
+          inputs:
+            my_input1:
+              type: MyType1
+""", dict(name=name)).assert_failure()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
index be5ad43..5f285ea 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
@@ -26,6 +26,7 @@ SECTIONS = (
     ('data', 'properties'),
     ('capability', 'properties'),
     ('capability', 'attributes'),
+    ('interface', 'inputs'),
     ('relationship', 'properties'),
     ('relationship', 'attributes'),
     ('node', 'properties'),
@@ -63,6 +64,21 @@ tosca_definitions_version: tosca_simple_yaml_1_0
 """, dict(name=name, parameter_section=parameter_section)).assert_success()
 
 
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+  MyType:
+    {{ parameter_section }}:
+      參數:
+        type: string
+        description: 描述
+        default: 值
+        status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
 # Status
 
 @pytest.mark.parametrize(
@@ -91,7 +107,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
     {{ parameter_section }}:
       my_param:
         type: string
-        status: bad
+        status: not a status
 """, dict(name=name, parameter_section=parameter_section)).assert_failure()
 
 


Mime
View raw message