summaryrefslogtreecommitdiffstats
path: root/tosca2heat/heat-translator/translator/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/heat-translator/translator/tests')
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_generate_keys.sh4
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_import_public_key.sh3
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/hot_exchange_public_ssh_key.yaml55
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/hot_get_functions_semantic.yaml52
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/hot_interface_on_compute.yaml44
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/hot_script_types.yaml101
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/test_tosca_get_functions_semantic.yaml84
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/test_tosca_interface_on_compute.yaml48
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/test_tosca_script_types.yaml48
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/tosca_exchange_public_ssh_key.yaml54
-rw-r--r--tosca2heat/heat-translator/translator/tests/test_shell.py54
-rw-r--r--tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py380
12 files changed, 636 insertions, 291 deletions
diff --git a/tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_generate_keys.sh b/tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_generate_keys.sh
new file mode 100644
index 0000000..9dc8e16
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_generate_keys.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+test -d /root/.ssh || mkdir /root/.ssh
+test -f /root/.ssh/id_rsa.pub || ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa
+cat /root/.ssh/id_rsa.pub > ${heat_outputs_path}.public_key
diff --git a/tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_import_public_key.sh b/tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_import_public_key.sh
new file mode 100644
index 0000000..1ef94e0
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/artifacts/ssh/ssh_import_public_key.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+test -d /root/.ssh || mkdir /root/.ssh
+echo "$public_key" >> /root/.ssh/authorized_keys
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_exchange_public_ssh_key.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_exchange_public_ssh_key.yaml
new file mode 100644
index 0000000..1dfa125
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_exchange_public_ssh_key.yaml
@@ -0,0 +1,55 @@
+heat_template_version: 2013-05-23
+
+description: >
+ TOSCA template to test get_operation_output by exchanging ssh public key
+
+parameters: {}
+resources:
+ generate_ssh_key_create_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: generate_ssh_key_create_config
+ server:
+ get_resource: server1
+ import_public_key_create_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: import_public_key_create_config
+ input_values:
+ public_key:
+ get_attr:
+ - generate_ssh_key_create_deploy
+ - public_key
+ server:
+ get_resource: server2
+ depends_on:
+ - generate_ssh_key_create_deploy
+ server1:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.small
+ image: ubuntu-12.04-software-config-os-init
+ user_data_format: SOFTWARE_CONFIG
+ server2:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.small
+ image: ubuntu-12.04-software-config-os-init
+ user_data_format: SOFTWARE_CONFIG
+ generate_ssh_key_create_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: artifacts/ssh/ssh_generate_keys.sh
+ group: script
+ outputs:
+ - name: public_key
+ import_public_key_create_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: artifacts/ssh/ssh_import_public_key.sh
+ group: script
+outputs: {} \ No newline at end of file
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_get_functions_semantic.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_get_functions_semantic.yaml
new file mode 100644
index 0000000..318a739
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_get_functions_semantic.yaml
@@ -0,0 +1,52 @@
+heat_template_version: 2013-05-23
+
+description: >
+ TOSCA template to test get_* functions semantic
+
+parameters:
+ map_val:
+ type: string
+resources:
+ myapp_configure_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ input_values:
+ list_val: list_val_0
+ config:
+ get_resource: myapp_configure_config
+ server:
+ get_resource: server
+ depends_on:
+ - mysql_database
+ server:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.small
+ image: ubuntu-12.04-software-config-os-init
+ user_data_format: SOFTWARE_CONFIG
+ myapp_configure_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ group: script
+ config:
+ get_file: myapp_configure.sh
+outputs:
+ map_val:
+ description: map_val
+ value:
+ get_input: map_val
+ concat_map_val:
+ value:
+ str_replace:
+ params:
+ $s2: :8080
+ $s0: http://
+ $s1:
+ get_input: map_val
+ template: $s0$s1$s2
+ static_map_val:
+ value: static_value
+ test_list_of_functions:
+ value:
+ - get_input: map_val
+ - static_value
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_interface_on_compute.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_interface_on_compute.yaml
new file mode 100644
index 0000000..0399c06
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_interface_on_compute.yaml
@@ -0,0 +1,44 @@
+heat_template_version: 2013-05-23
+
+description: >
+ TOSCA template to test Compute node with interface
+
+parameters: {}
+resources:
+ softwarecomponent_depending_on_customcompute_install_create_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: softwarecomponent_depending_on_customcompute_install_create_config
+ server:
+ get_resource: server
+ depends_on:
+ - server_create_deploy
+ server:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.small
+ image: ubuntu-12.04-software-config-os-init
+ user_data_format: SOFTWARE_CONFIG
+ softwarecomponent_depending_on_customcompute_install_create_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: post_install.sh
+ group: script
+ server_create_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: install.sh
+ group: script
+ server_create_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: server_create_config
+ input_values:
+ install_path: /opt
+ server:
+ get_resource: server
+outputs: {} \ No newline at end of file
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_script_types.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_script_types.yaml
new file mode 100644
index 0000000..5f0585d
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/hot_script_types.yaml
@@ -0,0 +1,101 @@
+heat_template_version: 2013-05-23
+
+description: >
+ TOSCA template to test usage of different script types like Ansible and Puppet
+ one.
+
+parameters: {}
+resources:
+ customwebserver2_create_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: customwebserver2_create_config
+ server:
+ get_resource: server
+ customwebserver_create_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: customwebserver_create_config
+ server:
+ get_resource: server
+ server:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.small
+ image: ubuntu-12.04-software-config-os-init
+ user_data_format: SOFTWARE_CONFIG
+ customwebserver2_start_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: start.sh
+ group: script
+ customwebserver2_start_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: customwebserver2_start_config
+ server:
+ get_resource: server
+ depends_on:
+ - customwebserver2_configure_deploy
+ customwebserver2_create_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: install.sh
+ group: script
+ customwebserver2_configure_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: configure.py
+ group: script
+ customwebserver2_configure_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: customwebserver2_configure_config
+ server:
+ get_resource: server
+ depends_on:
+ - customwebserver2_create_deploy
+ customwebserver_start_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: start.pp
+ group: puppet
+ customwebserver_start_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: customwebserver_start_config
+ server:
+ get_resource: server
+ depends_on:
+ - customwebserver_configure_deploy
+ customwebserver_create_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: install.yaml
+ group: ansible
+ customwebserver_configure_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ config:
+ get_file: configure.yml
+ group: ansible
+ customwebserver_configure_deploy:
+ type: OS::Heat::SoftwareDeployment
+ properties:
+ config:
+ get_resource: customwebserver_configure_config
+ server:
+ get_resource: server
+ depends_on:
+ - customwebserver_create_deploy
+outputs: {}
diff --git a/tosca2heat/heat-translator/translator/tests/data/test_tosca_get_functions_semantic.yaml b/tosca2heat/heat-translator/translator/tests/data/test_tosca_get_functions_semantic.yaml
new file mode 100644
index 0000000..2a76978
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/test_tosca_get_functions_semantic.yaml
@@ -0,0 +1,84 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: TOSCA template to test get_* functions semantic
+
+node_types:
+ tosca.capabilities.MyFeature:
+ derived_from: tosca.capabilities.Root
+ properties:
+ my_list:
+ type: list
+ my_map:
+ type: map
+
+ tosca.nodes.WebApplication.MyApp:
+ derived_from: tosca.nodes.WebApplication
+ requirements:
+ - myfeature:
+ capability: tosca.capabilities.MyFeature
+ node: tosca.nodes.MyDatabase
+ relationship: tosca.relationships.ConnectsTo
+
+ tosca.nodes.MyDatabase:
+ derived_from: tosca.nodes.Database
+ capabilities:
+ myfeature:
+ type: tosca.capabilities.MyFeature
+
+topology_template:
+ inputs:
+ map_val:
+ type: string
+
+ node_templates:
+ server:
+ type: tosca.nodes.Compute
+ capabilities:
+ host:
+ properties:
+ num_cpus: 1
+ mem_size: 1 GB
+ os:
+ properties:
+ type: Linux
+ distribution: Ubuntu
+ version: 12.04
+ architecture: x86_64
+
+ mysql_database:
+ type: tosca.nodes.MyDatabase
+ requirements:
+ - host: server
+ capabilities:
+ myfeature:
+ properties:
+ my_list: [list_val_0]
+ my_map:
+ test_key: { get_input: map_val }
+ test_key_static: static_value
+
+ myapp:
+ type: tosca.nodes.WebApplication.MyApp
+ requirements:
+ - myfeature: mysql_database
+ - host: server
+ interfaces:
+ Standard:
+ configure:
+ implementation: myapp_configure.sh
+ inputs:
+ list_val: { get_property: [ SELF, myfeature, my_list, 0 ] }
+
+ outputs:
+ map_val:
+ description: map_val
+ value: { get_property: [ myapp, myfeature, my_map, test_key ] }
+
+ static_map_val:
+ value: { get_property: [ myapp, myfeature, my_map, test_key_static ] }
+
+ concat_map_val:
+ value: { concat: [ 'http://', { get_property: [ myapp, myfeature, my_map, test_key ] }, ':8080' ] }
+
+ test_list_of_functions:
+ value: [ { get_property: [ myapp, myfeature, my_map, test_key ] }, { get_property: [ myapp, myfeature, my_map, test_key_static ] } ]
diff --git a/tosca2heat/heat-translator/translator/tests/data/test_tosca_interface_on_compute.yaml b/tosca2heat/heat-translator/translator/tests/data/test_tosca_interface_on_compute.yaml
new file mode 100644
index 0000000..e033c3c
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/test_tosca_interface_on_compute.yaml
@@ -0,0 +1,48 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: TOSCA template to test Compute node with interface
+
+node_types:
+ tosca.nodes.CustomCompute:
+ derived_from: tosca.nodes.Compute
+ properties:
+ install_path:
+ type: string
+ default: /opt
+ interfaces:
+ Standard:
+ create:
+ implementation: install.sh
+ inputs:
+ install_path: { get_property: [ SELF, install_path ] }
+
+topology_template:
+ node_templates:
+
+ softwarecomponent_without_behavior:
+ type: tosca.nodes.SoftwareComponent
+ requirements:
+ - host: server
+
+ softwarecomponent_depending_on_customcompute_install:
+ type: tosca.nodes.SoftwareComponent
+ interfaces:
+ Standard:
+ create:
+ implementation: post_install.sh
+ requirements:
+ - host: server
+
+ server:
+ type: tosca.nodes.CustomCompute
+ capabilities:
+ host:
+ properties:
+ num_cpus: 1
+ mem_size: 1 GB
+ os:
+ properties:
+ type: Linux
+ distribution: Ubuntu
+ version: 12.04
+ architecture: x86_64
diff --git a/tosca2heat/heat-translator/translator/tests/data/test_tosca_script_types.yaml b/tosca2heat/heat-translator/translator/tests/data/test_tosca_script_types.yaml
new file mode 100644
index 0000000..b54cbcb
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/test_tosca_script_types.yaml
@@ -0,0 +1,48 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: >
+ TOSCA template to test usage of different script types like
+ Ansible and Puppet one.
+
+topology_template:
+
+ node_templates:
+ customwebserver:
+ type: tosca.nodes.WebServer
+ requirements:
+ - host: server
+ interfaces:
+ Standard:
+ create:
+ implementation: install.yaml
+ configure:
+ implementation: configure.yml
+ start:
+ implementation: start.pp
+
+ customwebserver2:
+ type: tosca.nodes.WebServer
+ requirements:
+ - host: server
+ interfaces:
+ Standard:
+ create:
+ implementation: install.sh
+ configure:
+ implementation: configure.py
+ start:
+ implementation: start.sh
+
+ server:
+ type: tosca.nodes.Compute
+ capabilities:
+ host:
+ properties:
+ num_cpus: 1
+ mem_size: 1 GB
+ os:
+ properties:
+ type: Linux
+ distribution: Ubuntu
+ version: 12.04
+ architecture: x86_64
diff --git a/tosca2heat/heat-translator/translator/tests/data/tosca_exchange_public_ssh_key.yaml b/tosca2heat/heat-translator/translator/tests/data/tosca_exchange_public_ssh_key.yaml
new file mode 100644
index 0000000..7decb33
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/tosca_exchange_public_ssh_key.yaml
@@ -0,0 +1,54 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: TOSCA template to test get_operation_output by exchanging ssh public key
+
+topology_template:
+
+ node_templates:
+ server1:
+ type: tosca.nodes.Compute
+ capabilities:
+ host:
+ properties:
+ num_cpus: 1
+ mem_size: 1 GB
+ os:
+ properties:
+ type: Linux
+ distribution: Ubuntu
+ version: 12.04
+ architecture: x86_64
+
+ server2:
+ type: tosca.nodes.Compute
+ capabilities:
+ host:
+ properties:
+ num_cpus: 1
+ mem_size: 1 GB
+ os:
+ properties:
+ type: Linux
+ distribution: Ubuntu
+ version: 12.04
+ architecture: x86_64
+
+ generate_ssh_key:
+ type: tosca.nodes.SoftwareComponent
+ interfaces:
+ Standard:
+ create: artifacts/ssh/ssh_generate_keys.sh
+ requirements:
+ - host: server1
+
+ import_public_key:
+ type: tosca.nodes.SoftwareComponent
+ interfaces:
+ Standard:
+ create:
+ implementation: artifacts/ssh/ssh_import_public_key.sh
+ inputs:
+ public_key: { get_operation_output: [generate_ssh_key, Standard, create, public_key] }
+ requirements:
+ - host: server2
+ - dependency: generate_ssh_key
diff --git a/tosca2heat/heat-translator/translator/tests/test_shell.py b/tosca2heat/heat-translator/translator/tests/test_shell.py
index b001c1a..62f3510 100644
--- a/tosca2heat/heat-translator/translator/tests/test_shell.py
+++ b/tosca2heat/heat-translator/translator/tests/test_shell.py
@@ -29,28 +29,9 @@ class ShellTest(TestCase):
"data/tosca_helloworld.yaml")
template_file = '--template-file=' + tosca_helloworld
template_type = '--template-type=tosca'
- template_validation = "--validate-only=true"
+ template_validation = "--validate-only"
failure_msg = _('The program raised an exception unexpectedly.')
- def test_missing_arg(self):
- error = self.assertRaises(ValueError, shell.main, '')
- err_msg = _('The program requires minimum two arguments. '
- 'Please refer to the usage documentation.')
- self.assertEqual(err_msg, str(error))
-
- def test_invalid_file_arg(self):
- error = self.assertRaises(ValueError, shell.main, 'translate me')
- err_msg = _('The program expects --template-file as first '
- 'argument. Please refer to the usage documentation.')
- self.assertEqual(err_msg, str(error))
-
- def test_invalid_type_arg(self):
- error = self.assertRaises(ValueError,
- shell.main, ('--template-file=', 'xyz'))
- err_msg = _('The program expects --template-type as second argument. '
- 'Please refer to the usage documentation.')
- self.assertEqual(err_msg, str(error))
-
def test_invalid_file_value(self):
error = self.assertRaises(ValueError,
shell.main, ('--template-file=template.txt',
@@ -59,17 +40,13 @@ class ShellTest(TestCase):
self.assertEqual(err_msg, str(error))
def test_invalid_type_value(self):
- error = self.assertRaises(ValueError, shell.main,
- (self.template_file, '--template-type=xyz'))
- err_msg = _('xyz is not a valid template type.')
- self.assertEqual(err_msg, str(error))
+ self.assertRaises(SystemExit, shell.main,
+ (self.template_file, '--template-type=xyz'))
def test_invalid_parameters(self):
- error = self.assertRaises(ValueError, shell.main,
- (self.template_file, self.template_type,
- '--parameters=key'))
- err_msg = _("'key' is not a well-formed parameter.")
- self.assertEqual(err_msg, str(error))
+ self.assertRaises(ValueError, shell.main,
+ (self.template_file, self.template_type,
+ '--parameters=key'))
def test_valid_template(self):
try:
@@ -77,6 +54,12 @@ class ShellTest(TestCase):
except Exception:
self.fail(self.failure_msg)
+ def test_valid_template_without_type(self):
+ try:
+ shell.main([self.template_file])
+ except Exception:
+ self.fail(self.failure_msg)
+
def test_valid_template_with_parameters(self):
tosca_single_instance_wordpress = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
@@ -126,7 +109,10 @@ class ShellTest(TestCase):
@patch('os.getenv')
@patch('translator.hot.tosca.tosca_compute.'
'ToscaCompute._create_nova_flavor_dict')
- def test_template_deploy_with_credentials(self, mock_flavor_dict,
+ @patch('translator.hot.tosca.tosca_compute.'
+ 'ToscaCompute._populate_image_dict')
+ def test_template_deploy_with_credentials(self, mock_populate_image_dict,
+ mock_flavor_dict,
mock_os_getenv,
mock_token,
mock_url, mock_post,
@@ -137,6 +123,14 @@ class ShellTest(TestCase):
mock_flavor_dict.return_value = {
'm1.medium': {'mem_size': 4096, 'disk_size': 40, 'num_cpus': 2}
}
+ mock_populate_image_dict.return_value = {
+ "rhel-6.5-test-image": {
+ "version": "6.5",
+ "architecture": "x86_64",
+ "distribution": "RHEL",
+ "type": "Linux"
+ }
+ }
mock_url.return_value = 'http://abc.com'
mock_token.return_value = 'mock_token'
mock_os_getenv.side_effect = ['demo', 'demo',
diff --git a/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py b/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py
index e58d842..7a89827 100644
--- a/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py
+++ b/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py
@@ -23,35 +23,48 @@ from translator.tests.base import TestCase
class ToscaHotTranslationTest(TestCase):
- def test_hot_translate_single_server(self):
- tosca_file = '../tests/data/tosca_single_server.yaml'
- hot_file = '../tests/data/hot_output/hot_single_server.yaml'
- params = {'cpus': 1}
+ def _test_successful_translation(self, tosca_file, hot_file, params=None):
+ if not params:
+ params = {}
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
hot_file,
params)
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))
+ def _test_failed_translation(self, tosca_file, hot_file, params, msg,
+ msg_path, error_raise, error_collect):
+ if msg_path:
+ path = os.path.normpath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), tosca_file))
+ msg = msg % path
+ self.assertRaises(
+ error_raise,
+ TranslationUtils.compare_tosca_translation_with_hot,
+ tosca_file, hot_file, params)
+ ExceptionCollector.assertExceptionMessage(error_collect, msg)
+
+ def test_hot_translate_single_server(self):
+ tosca_file = '../tests/data/tosca_single_server.yaml'
+ hot_file = '../tests/data/hot_output/hot_single_server.yaml'
+ params = {'cpus': 1}
+ self._test_successful_translation(tosca_file, hot_file, params)
+
def test_hot_translate_single_server_with_defaults(self):
tosca_file = \
'../tests/data/tosca_single_server_with_defaults.yaml'
+
hot_file_with_input = '../tests/data/hot_output/' \
'hot_single_server_with_defaults_with_input.yaml'
- hot_file_without_input = '../tests/data/hot_output/' \
- 'hot_single_server_with_defaults_without_input.yaml'
-
params1 = {'cpus': '1'}
- diff1 = TranslationUtils.compare_tosca_translation_with_hot(
- tosca_file, hot_file_with_input, params1)
- self.assertEqual({}, diff1, '<difference> : ' +
- json.dumps(diff1, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file_with_input,
+ params1)
+ hot_file_without_input = '../tests/data/hot_output/' \
+ 'hot_single_server_with_defaults_without_input.yaml'
params2 = {}
- diff2 = TranslationUtils.compare_tosca_translation_with_hot(
- tosca_file, hot_file_without_input, params2)
- self.assertEqual({}, diff2, '<difference> : ' +
- json.dumps(diff2, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file_without_input,
+ params2)
def test_hot_translate_wordpress_single_instance(self):
tosca_file = '../tests/data/tosca_single_instance_wordpress.yaml'
@@ -63,29 +76,17 @@ class ToscaHotTranslationTest(TestCase):
'db_root_pwd': 'passw0rd',
'db_port': 3366,
'cpus': 8}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_helloworld(self):
tosca_file = '../tests/data/tosca_helloworld.yaml'
hot_file = '../tests/data/hot_output/hot_hello_world.yaml'
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- {})
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file)
def test_hot_translate_host_assignment(self):
tosca_file = '../tests/data/test_host_assignment.yaml'
hot_file = '../tests/data/hot_output/hot_host_assignment.yaml'
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- {})
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file)
def test_hot_translate_elk(self):
tosca_file = '../tests/data/tosca_elk.yaml'
@@ -93,11 +94,7 @@ class ToscaHotTranslationTest(TestCase):
params = {'github_url':
'http://github.com/paypal/rest-api-sample-app-nodejs.git',
'my_cpus': 4}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_nodejs_mongodb_two_instances(self):
tosca_file = '../tests/data/tosca_nodejs_mongodb_two_instances.yaml'
@@ -106,11 +103,7 @@ class ToscaHotTranslationTest(TestCase):
params = {'github_url':
'http://github.com/paypal/rest-api-sample-app-nodejs.git',
'my_cpus': 4}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_blockstorage_with_attachment(self):
tosca_file = '../tests/data/storage/' \
@@ -121,11 +114,7 @@ class ToscaHotTranslationTest(TestCase):
'storage_location': '/dev/vdc',
'storage_size': '2000 MB',
'storage_snapshot_id': 'ssid'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_blockstorage_with_custom_relationship_type(self):
tosca_file = '../tests/data/storage/' \
@@ -136,11 +125,7 @@ class ToscaHotTranslationTest(TestCase):
'storage_location': '/dev/vdc',
'storage_size': '1 GB',
'storage_snapshot_id': 'ssid'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_blockstorage_with_relationship_template(self):
tosca_file = '../tests/data/storage/' \
@@ -150,11 +135,7 @@ class ToscaHotTranslationTest(TestCase):
params = {'cpus': 1,
'storage_location': '/dev/vdc',
'storage_size': '1 GB'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_blockstorage_with_attachment_notation1(self):
tosca_file = '../tests/data/storage/' \
@@ -167,19 +148,11 @@ class ToscaHotTranslationTest(TestCase):
'storage_location': 'some_folder',
'storage_size': '1 GB',
'storage_snapshot_id': 'ssid'}
- diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file1,
- params)
+
try:
- self.assertEqual({}, diff1, '<difference> : ' +
- json.dumps(diff1, indent=4,
- separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file1, params)
except Exception:
- diff2 = TranslationUtils.compare_tosca_translation_with_hot(
- tosca_file, hot_file2, params)
- self.assertEqual({}, diff2, '<difference> : ' +
- json.dumps(diff2, indent=4,
- separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file2, params)
def test_hot_translate_blockstorage_with_attachment_notation2(self):
tosca_file = '../tests/data/storage/' \
@@ -192,19 +165,10 @@ class ToscaHotTranslationTest(TestCase):
'storage_location': '/dev/vdc',
'storage_size': '1 GB',
'storage_snapshot_id': 'ssid'}
- diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file1,
- params)
try:
- self.assertEqual({}, diff1, '<difference> : ' +
- json.dumps(diff1, indent=4,
- separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file1, params)
except Exception:
- diff2 = TranslationUtils.compare_tosca_translation_with_hot(
- tosca_file, hot_file2, params)
- self.assertEqual({}, diff2, '<difference> : ' +
- json.dumps(diff2, indent=4,
- separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file2, params)
def test_hot_translate_multiple_blockstorage_with_attachment(self):
tosca_file = '../tests/data/storage/' \
@@ -217,40 +181,23 @@ class ToscaHotTranslationTest(TestCase):
'storage_location': '/dev/vdc',
'storage_size': '1 GB',
'storage_snapshot_id': 'ssid'}
- diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file1,
- params)
try:
- self.assertEqual({}, diff1, '<difference> : ' +
- json.dumps(diff1, indent=4,
- separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file1, params)
except Exception:
- diff2 = TranslationUtils.compare_tosca_translation_with_hot(
- tosca_file, hot_file2, params)
- self.assertEqual({}, diff2, '<difference> : ' +
- json.dumps(diff2, indent=4,
- separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file2, params)
def test_hot_translate_single_object_store(self):
tosca_file = '../tests/data/storage/tosca_single_object_store.yaml'
hot_file = '../tests/data/hot_output/hot_single_object_store.yaml'
params = {'objectstore_name': 'myobjstore'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_one_server_one_network(self):
tosca_file = '../tests/data/network/tosca_one_server_one_network.yaml'
hot_file = '../tests/data/hot_output/network/' \
'hot_one_server_one_network.yaml'
params = {'network_name': 'private_net'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_server_on_existing_network(self):
tosca_file = '../tests/data/network/' \
@@ -258,11 +205,7 @@ class ToscaHotTranslationTest(TestCase):
hot_file = '../tests/data/hot_output/network/' \
'hot_server_on_existing_network.yaml'
params = {'network_name': 'private_net'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_two_servers_one_network(self):
tosca_file = '../tests/data/network/tosca_two_servers_one_network.yaml'
@@ -272,11 +215,7 @@ class ToscaHotTranslationTest(TestCase):
'network_cidr': '10.0.0.0/24',
'network_start_ip': '10.0.0.100',
'network_end_ip': '10.0.0.150'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_one_server_three_networks(self):
tosca_file = '../tests/data/network/' \
@@ -284,32 +223,20 @@ class ToscaHotTranslationTest(TestCase):
hot_file = '../tests/data/hot_output/network/' \
'hot_one_server_three_networks.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_software_component(self):
tosca_file = '../tests/data/tosca_software_component.yaml'
hot_file = '../tests/data/hot_output/hot_software_component.yaml'
params = {'cpus': '1',
'download_url': 'http://www.software.com/download'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_web_application(self):
tosca_file = '../tests/data/tosca_web_application.yaml'
hot_file = '../tests/data/hot_output/hot_web_application.yaml'
params = {'cpus': '2', 'context_root': 'my_web_app'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_template_with_url_import(self):
tosca_file = '../tests/data/' \
@@ -322,11 +249,7 @@ class ToscaHotTranslationTest(TestCase):
'db_root_pwd': 'passw0rd',
'db_port': 3366,
'cpus': 8}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_template_by_url_with_local_import(self):
tosca_file = 'https://raw.githubusercontent.com/openstack/' \
@@ -340,11 +263,7 @@ class ToscaHotTranslationTest(TestCase):
'db_root_pwd': 'passw0rd',
'db_port': 3366,
'cpus': 8}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_template_by_url_with_local_abspath_import(self):
tosca_file = 'https://raw.githubusercontent.com/openstack/' \
@@ -359,17 +278,15 @@ class ToscaHotTranslationTest(TestCase):
'db_root_pwd': 'passw0rd',
'db_port': 3366,
'cpus': 8}
-
- self.assertRaises(
- ValidationError,
- TranslationUtils.compare_tosca_translation_with_hot,
- tosca_file, hot_file, params)
expected_msg = _('Absolute file name "/tmp/wordpress.yaml" cannot be '
'used in a URL-based input template "https://raw.'
'githubusercontent.com/openstack/heat-translator/'
'master/translator/tests/data/tosca_single_instance_'
'wordpress_with_local_abspath_import.yaml".')
- ExceptionCollector.assertExceptionMessage(ImportError, expected_msg)
+ msg_path = False
+ self._test_failed_translation(tosca_file, hot_file, params,
+ expected_msg, msg_path, ValidationError,
+ ImportError)
def test_hot_translate_template_by_url_with_url_import(self):
tosca_url = 'https://raw.githubusercontent.com/openstack/' \
@@ -383,20 +300,12 @@ class ToscaHotTranslationTest(TestCase):
'db_root_pwd': 'passw0rd',
'db_port': 3366,
'cpus': 8}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_url,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_url, hot_file, params)
def test_translate_hello_world_csar(self):
tosca_file = '../tests/data/csar_hello_world.zip'
hot_file = '../tests/data/hot_output/hot_hello_world.yaml'
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- {})
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file)
def test_translate_single_instance_wordpress_csar(self):
tosca_file = '../tests/data/csar_single_instance_wordpress.zip'
@@ -408,11 +317,7 @@ class ToscaHotTranslationTest(TestCase):
'db_root_pwd': 'passw0rd',
'db_port': 3366,
'cpus': 8}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_translate_elk_csar_from_url(self):
tosca_file = 'https://github.com/openstack/heat-translator/raw/' \
@@ -421,150 +326,103 @@ class ToscaHotTranslationTest(TestCase):
params = {'github_url':
'http://github.com/paypal/rest-api-sample-app-nodejs.git',
'my_cpus': 4}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_translate_csar_not_zip(self):
tosca_file = '../tests/data/csar_not_zip.zip'
hot_file = ''
params = {}
-
- self.assertRaises(
- ValidationError,
- TranslationUtils.compare_tosca_translation_with_hot,
- tosca_file, hot_file, params)
- path = os.path.normpath(os.path.join(
- os.path.dirname(os.path.realpath(__file__)), tosca_file))
- expected_msg = _('"%s" is not a valid zip file.') % path
- ExceptionCollector.assertExceptionMessage(ValidationError,
- expected_msg)
+ expected_msg = _('"%s" is not a valid zip file.')
+ msg_path = True
+ self._test_failed_translation(tosca_file, hot_file, params,
+ expected_msg, msg_path, ValidationError,
+ ValidationError)
def test_translate_csar_metadata_not_yaml(self):
tosca_file = '../tests/data/csar_metadata_not_yaml.zip'
hot_file = ''
params = {}
-
- self.assertRaises(
- ValidationError,
- TranslationUtils.compare_tosca_translation_with_hot,
- tosca_file, hot_file, params)
- path = os.path.normpath(os.path.join(
- os.path.dirname(os.path.realpath(__file__)), tosca_file))
expected_msg = _('The file "TOSCA-Metadata/TOSCA.meta" in the CSAR '
- '"%s" does not contain valid YAML content.') % path
- ExceptionCollector.assertExceptionMessage(ValidationError,
- expected_msg)
+ '"%s" does not contain valid YAML content.')
+ msg_path = True
+ self._test_failed_translation(tosca_file, hot_file, params,
+ expected_msg, msg_path, ValidationError,
+ ValidationError)
def test_translate_csar_wrong_metadata_file(self):
tosca_file = '../tests/data/csar_wrong_metadata_file.zip'
hot_file = ''
params = {}
-
- self.assertRaises(
- ValidationError,
- TranslationUtils.compare_tosca_translation_with_hot,
- tosca_file, hot_file, params)
- path = os.path.normpath(os.path.join(
- os.path.dirname(os.path.realpath(__file__)), tosca_file))
expected_msg = _('"%s" is not a valid CSAR as it does not contain the '
'required file "TOSCA.meta" in the folder '
- '"TOSCA-Metadata".') % path
- ExceptionCollector.assertExceptionMessage(ValidationError,
- expected_msg)
+ '"TOSCA-Metadata".')
+ msg_path = True
+ self._test_failed_translation(tosca_file, hot_file, params,
+ expected_msg, msg_path, ValidationError,
+ ValidationError)
def test_translate_csar_wordpress_invalid_import_path(self):
tosca_file = '../tests/data/csar_wordpress_invalid_import_path.zip'
hot_file = ''
params = {}
-
- self.assertRaises(
- ValidationError,
- TranslationUtils.compare_tosca_translation_with_hot,
- tosca_file, hot_file, params)
expected_msg = _('Import '
'"Invalid_import_path/wordpress.yaml" is not valid.')
- ExceptionCollector.assertExceptionMessage(ImportError, expected_msg)
+ msg_path = False
+ self._test_failed_translation(tosca_file, hot_file, params,
+ expected_msg, msg_path, ValidationError,
+ ImportError)
def test_translate_csar_wordpress_invalid_script_url(self):
tosca_file = '../tests/data/csar_wordpress_invalid_script_url.zip'
hot_file = ''
params = {}
-
- self.assertRaises(
- ValidationError,
- TranslationUtils.compare_tosca_translation_with_hot,
- tosca_file, hot_file, params)
expected_msg = _('The resource at '
'"https://raw.githubusercontent.com/openstack/'
'heat-translator/master/translator/tests/data/'
'custom_types/wordpress1.yaml" cannot be accessed.')
- ExceptionCollector.assertExceptionMessage(URLException, expected_msg)
+ msg_path = False
+ self._test_failed_translation(tosca_file, hot_file, params,
+ expected_msg, msg_path, ValidationError,
+ URLException)
def test_hot_translate_flavor_image(self):
tosca_file = '../tests/data/test_tosca_flavor_and_image.yaml'
hot_file = '../tests/data/hot_output/hot_flavor_and_image.yaml'
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- {})
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file)
def test_hot_translate_flavor_image_params(self):
tosca_file = '../tests/data/test_tosca_flavor_and_image.yaml'
hot_file = '../tests/data/hot_output/hot_flavor_and_image_params.yaml'
params = {'key_name': 'paramkey'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_custom_type(self):
tosca_file = '../tests/data/test_tosca_custom_type.yaml'
hot_file = '../tests/data/hot_output/' \
'hot_custom_type.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_custom_type_with_override(self):
tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
hot_file = '../tests/data/hot_output/' \
'hot_custom_type_with_override.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_custom_type_with_param_override(self):
tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
hot_file = '../tests/data/hot_output/' \
'hot_custom_type_with_param_override.yaml'
params = {'install_path': '/home/custom/from/cli'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_artifact(self):
tosca_file = '../tests/data/test_tosca_artifact.yaml'
hot_file = '../tests/data/hot_output/' \
'hot_artifact.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_without_tosca_os_version(self):
tosca_file = '../tests/data/' \
@@ -572,21 +430,13 @@ class ToscaHotTranslationTest(TestCase):
hot_file = '../tests/data/hot_output/' \
'hot_single_server_without_tosca_os_version.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_helloworld_with_userkey(self):
tosca_file = '../tests/data/tosca_helloworld.yaml'
hot_file = '../tests/data/hot_output/hot_hello_world_userkey.yaml'
params = {'key_name': 'userkey'}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_custom_networks_nodes_inline(self):
tosca_file = '../tests/data/network/' \
@@ -594,11 +444,7 @@ class ToscaHotTranslationTest(TestCase):
hot_file = '../tests/data/hot_output/network/' \
'hot_custom_network_nodes.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_custom_networks_nodes_imports(self):
tosca_file = '../tests/data/network/' \
@@ -606,28 +452,40 @@ class ToscaHotTranslationTest(TestCase):
hot_file = '../tests/data/hot_output/network/' \
'hot_custom_network_nodes.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_nfv_sample(self):
tosca_file = '../tests/data/test_tosca_nfv_sample.yaml'
hot_file = '../tests/data/hot_output/hot_nfv_sample.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
def test_hot_translate_policy(self):
tosca_file = '../tests/data/tosca_policies.yaml'
hot_file = '../tests/data/hot_output/hot_policies.yaml'
params = {}
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_file,
- params)
- self.assertEqual({}, diff, '<difference> : ' +
- json.dumps(diff, indent=4, separators=(', ', ': ')))
+ self._test_successful_translation(tosca_file, hot_file, params)
+
+ def test_hot_script_types(self):
+ tosca_file = '../tests/data/test_tosca_script_types.yaml'
+ hot_file = '../tests/data/hot_output/hot_script_types.yaml'
+ params = {}
+ self._test_successful_translation(tosca_file, hot_file, params)
+
+ def test_hot_interface_on_compute(self):
+ tosca_file = '../tests/data/test_tosca_interface_on_compute.yaml'
+ hot_file = '../tests/data/hot_output/hot_interface_on_compute.yaml'
+ params = {}
+ self._test_successful_translation(tosca_file, hot_file, params)
+
+ def test_hot_get_functions_semantic(self):
+ tosca_file = '../tests/data/test_tosca_get_functions_semantic.yaml'
+ hot_file = '../tests/data/hot_output/hot_get_functions_semantic.yaml'
+ params = {}
+ self._test_successful_translation(tosca_file, hot_file, params)
+
+ def test_hot_exchange_public_ssh_key(self):
+ tosca_file = '../tests/data/tosca_exchange_public_ssh_key.yaml'
+ hot_file = '../tests/data/hot_output/hot_exchange_public_ssh_key.yaml'
+ params = {}
+ self._test_successful_translation(tosca_file, hot_file, params)