Synchronize upstream version of 0.9
[parser.git] / tosca2heat / heat-translator / translator / tests / test_tosca_hot_translation.py
1 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
2 #    not use this file except in compliance with the License. You may obtain
3 #    a copy of the License at
4 #
5 #         http://www.apache.org/licenses/LICENSE-2.0
6 #
7 #    Unless required by applicable law or agreed to in writing, software
8 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 #    License for the specific language governing permissions and limitations
11 #    under the License.
12
13 import json
14 import os
15
16 from toscaparser.common.exception import ExceptionCollector
17 from toscaparser.common.exception import URLException
18 from toscaparser.common.exception import ValidationError
19 from toscaparser.tosca_template import ToscaTemplate
20 from toscaparser.utils.gettextutils import _
21 from translator.common.exception import UnsupportedTypeError
22 from translator.common.utils import TranslationUtils
23 from translator.hot.tosca_translator import TOSCATranslator
24 from translator.tests.base import TestCase
25
26
27 class ToscaHotTranslationTest(TestCase):
28
29     def _test_successful_translation(self, tosca_file, hot_files, params=None,
30                                      nested_resources=False):
31         if not params:
32             params = {}
33         if not isinstance(hot_files, list):
34             hot_files = [hot_files]
35         diff =\
36             TranslationUtils.compare_tosca_translation_with_hot(
37                 tosca_file, hot_files, params, nested_resources)
38         self.assertEqual({}, diff, '<difference> : ' +
39                          json.dumps(diff, indent=4, separators=(', ', ': ')))
40
41     def _test_failed_translation(self, tosca_file, hot_file, params, msg,
42                                  msg_path, error_raise, error_collect):
43         if msg_path:
44             path = os.path.normpath(os.path.join(
45                 os.path.dirname(os.path.realpath(__file__)), tosca_file))
46             msg = msg % path
47         self.assertRaises(
48             error_raise,
49             TranslationUtils.compare_tosca_translation_with_hot,
50             tosca_file, hot_file, params)
51         ExceptionCollector.assertExceptionMessage(error_collect, msg)
52
53     def test_hot_translate_single_server(self):
54         tosca_file = '../tests/data/tosca_single_server.yaml'
55         hot_file = '../tests/data/hot_output/hot_single_server.yaml'
56         params = {'cpus': 1}
57         self._test_successful_translation(tosca_file, hot_file, params)
58
59     def test_hot_translate_single_server_with_defaults(self):
60         tosca_file = \
61             '../tests/data/tosca_single_server_with_defaults.yaml'
62
63         hot_file_with_input = '../tests/data/hot_output/' \
64             'hot_single_server_with_defaults_with_input.yaml'
65         params1 = {'cpus': '1'}
66         self._test_successful_translation(tosca_file, hot_file_with_input,
67                                           params1)
68
69         hot_file_without_input = '../tests/data/hot_output/' \
70             'hot_single_server_with_defaults_without_input.yaml'
71         params2 = {}
72         self._test_successful_translation(tosca_file, hot_file_without_input,
73                                           params2)
74
75     def test_hot_translate_wordpress_single_instance(self):
76         tosca_file = '../tests/data/tosca_single_instance_wordpress.yaml'
77         hot_file = '../tests/data/hot_output/' \
78             'hot_single_instance_wordpress.yaml'
79         params = {'db_name': 'wordpress',
80                   'db_user': 'wp_user',
81                   'db_pwd': 'wp_pass',
82                   'db_root_pwd': 'passw0rd',
83                   'db_port': 3366,
84                   'cpus': 8}
85         self._test_successful_translation(tosca_file, hot_file, params)
86
87     def test_hot_translate_helloworld(self):
88         tosca_file = '../tests/data/tosca_helloworld.yaml'
89         hot_file = '../tests/data/hot_output/hot_hello_world.yaml'
90         self._test_successful_translation(tosca_file, hot_file)
91
92     def test_hot_translate_host_assignment(self):
93         tosca_file = '../tests/data/test_host_assignment.yaml'
94         hot_file = '../tests/data/hot_output/hot_host_assignment.yaml'
95         self._test_successful_translation(tosca_file, hot_file)
96
97     def test_hot_translate_elk(self):
98         tosca_file = '../tests/data/tosca_elk.yaml'
99         hot_file = '../tests/data/hot_output/hot_elk.yaml'
100         params = {'github_url':
101                   'http://github.com/paypal/rest-api-sample-app-nodejs.git',
102                   'my_cpus': 4}
103         self._test_successful_translation(tosca_file, hot_file, params)
104
105     def test_hot_translate_nodejs_mongodb_two_instances(self):
106         tosca_file = '../tests/data/tosca_nodejs_mongodb_two_instances.yaml'
107         hot_file = '../tests/data/hot_output/' \
108                    'hot_nodejs_mongodb_two_instances.yaml'
109         params = {'github_url':
110                   'http://github.com/paypal/rest-api-sample-app-nodejs.git',
111                   'my_cpus': 4}
112         self._test_successful_translation(tosca_file, hot_file, params)
113
114     def test_hot_translate_blockstorage_with_attachment(self):
115         tosca_file = '../tests/data/storage/' \
116                      'tosca_blockstorage_with_attachment.yaml'
117         hot_file = '../tests/data/hot_output/storage/' \
118                    'hot_blockstorage_with_attachment.yaml'
119         params = {'cpus': 1,
120                   'storage_location': '/dev/vdc',
121                   'storage_size': '2000 MB',
122                   'storage_snapshot_id': 'ssid'}
123         self._test_successful_translation(tosca_file, hot_file, params)
124
125     def test_hot_translate_blockstorage_with_custom_relationship_type(self):
126         tosca_file = '../tests/data/storage/' \
127                      'tosca_blockstorage_with_custom_relationship_type.yaml'
128         hot_file = '../tests/data/hot_output/storage/' \
129                    'hot_blockstorage_with_custom_relationship_type.yaml'
130         params = {'cpus': 1,
131                   'storage_location': '/dev/vdc',
132                   'storage_size': '1 GB',
133                   'storage_snapshot_id': 'ssid'}
134         self._test_successful_translation(tosca_file, hot_file, params)
135
136     def test_hot_translate_blockstorage_with_relationship_template(self):
137         tosca_file = '../tests/data/storage/' \
138                      'tosca_blockstorage_with_relationship_template.yaml'
139         hot_file = '../tests/data/hot_output/storage/' \
140                    'hot_blockstorage_with_relationship_template.yaml'
141         params = {'cpus': 1,
142                   'storage_location': '/dev/vdc',
143                   'storage_size': '1 GB'}
144         self._test_successful_translation(tosca_file, hot_file, params)
145
146     def test_hot_translate_blockstorage_with_attachment_notation1(self):
147         tosca_file = '../tests/data/storage/' \
148                      'tosca_blockstorage_with_attachment_notation1.yaml'
149         hot_file1 = '../tests/data/hot_output/storage/' \
150                     'hot_blockstorage_with_attachment_notation1_alt1.yaml'
151         hot_file2 = '../tests/data/hot_output/storage/' \
152                     'hot_blockstorage_with_attachment_notation1_alt2.yaml'
153         params = {'cpus': 1,
154                   'storage_location': 'some_folder',
155                   'storage_size': '1 GB',
156                   'storage_snapshot_id': 'ssid'}
157
158         try:
159             self._test_successful_translation(tosca_file, hot_file1, params)
160         except Exception:
161             self._test_successful_translation(tosca_file, hot_file2, params)
162
163     def test_hot_translate_blockstorage_with_attachment_notation2(self):
164         tosca_file = '../tests/data/storage/' \
165                      'tosca_blockstorage_with_attachment_notation2.yaml'
166         hot_file1 = '../tests/data/hot_output/storage/' \
167                     'hot_blockstorage_with_attachment_notation2_alt1.yaml'
168         hot_file2 = '../tests/data/hot_output/storage/' \
169                     'hot_blockstorage_with_attachment_notation2_alt2.yaml'
170         params = {'cpus': 1,
171                   'storage_location': '/dev/vdc',
172                   'storage_size': '1 GB',
173                   'storage_snapshot_id': 'ssid'}
174         try:
175             self._test_successful_translation(tosca_file, hot_file1, params)
176         except Exception:
177             self._test_successful_translation(tosca_file, hot_file2, params)
178
179     def test_hot_translate_multiple_blockstorage_with_attachment(self):
180         tosca_file = '../tests/data/storage/' \
181                      'tosca_multiple_blockstorage_with_attachment.yaml'
182         hot_file1 = '../tests/data/hot_output/storage/' \
183                     'hot_multiple_blockstorage_with_attachment_alt1.yaml'
184         hot_file2 = '../tests/data/hot_output/storage/' \
185                     'hot_multiple_blockstorage_with_attachment_alt2.yaml'
186         params = {'cpus': 1,
187                   'storage_location': '/dev/vdc',
188                   'storage_size': '1 GB',
189                   'storage_snapshot_id': 'ssid'}
190         try:
191             self._test_successful_translation(tosca_file, hot_file1, params)
192         except Exception:
193             self._test_successful_translation(tosca_file, hot_file2, params)
194
195     def test_hot_translate_multiple_blockstorage_w_multiple_attachment(self):
196         tosca_file = '../tests/data/storage/' \
197                      'tosca_multiple_blockstorage_w_multiple_attachment.yaml'
198         hot_file = '../tests/data/hot_output/storage/' \
199                    'hot_multiple_blockstorage_w_multiple_attachment.yaml'
200         params = {'cpus': 1,
201                   'storage_location1': '/dev/vdb',
202                   'storage_location2': '/dev/vdc',
203                   'storage_size': '1 GB',
204                   'storage_snapshot_id': 'ssid'}
205         self._test_successful_translation(tosca_file, hot_file, params)
206
207     def test_hot_translate_single_object_store(self):
208         tosca_file = '../tests/data/storage/tosca_single_object_store.yaml'
209         hot_file = '../tests/data/hot_output/hot_single_object_store.yaml'
210         params = {'objectstore_name': 'myobjstore'}
211         self._test_successful_translation(tosca_file, hot_file, params)
212
213     def test_hot_translate_one_server_one_network(self):
214         tosca_file = '../tests/data/network/tosca_one_server_one_network.yaml'
215         hot_file = '../tests/data/hot_output/network/' \
216                    'hot_one_server_one_network.yaml'
217         params = {'network_name': 'private_net'}
218         self._test_successful_translation(tosca_file, hot_file, params)
219
220     def test_hot_translate_server_on_existing_network(self):
221         tosca_file = '../tests/data/network/' \
222                      'tosca_server_on_existing_network.yaml'
223         hot_file = '../tests/data/hot_output/network/' \
224                    'hot_server_on_existing_network.yaml'
225         params = {'network_name': 'private_net'}
226         self._test_successful_translation(tosca_file, hot_file, params)
227
228     def test_hot_translate_two_servers_one_network(self):
229         tosca_file = '../tests/data/network/tosca_two_servers_one_network.yaml'
230         hot_file = '../tests/data/hot_output/network/' \
231                    'hot_two_servers_one_network.yaml'
232         params = {'network_name': 'my_private_net',
233                   'network_cidr': '10.0.0.0/24',
234                   'network_start_ip': '10.0.0.100',
235                   'network_end_ip': '10.0.0.150'}
236         self._test_successful_translation(tosca_file, hot_file, params)
237
238     def test_hot_translate_one_server_three_networks(self):
239         tosca_file = '../tests/data/network/' \
240                      'tosca_one_server_three_networks.yaml'
241         hot_file = '../tests/data/hot_output/network/' \
242                    'hot_one_server_three_networks.yaml'
243         params = {}
244         self._test_successful_translation(tosca_file, hot_file, params)
245
246     def test_hot_translate_software_component(self):
247         tosca_file = '../tests/data/tosca_software_component.yaml'
248         hot_file = '../tests/data/hot_output/hot_software_component.yaml'
249         params = {'cpus': '1',
250                   'download_url': 'http://www.software.com/download'}
251         self._test_successful_translation(tosca_file, hot_file, params)
252
253     def test_hot_translate_software_component_multiple_hosts(self):
254         tosca_file = '../tests/data/tosca_software_component'\
255             '_multiple_hosts.yaml'
256         hot_file = '../tests/data/hot_output/hot_software_component'\
257             '_multiple_hosts.yaml'
258         params = {'cpus': '1',
259                   'download_url': 'http://www.software.com/download'}
260         self._test_successful_translation(tosca_file, hot_file, params)
261
262     def test_hot_translate_web_application(self):
263         tosca_file = '../tests/data/tosca_web_application.yaml'
264         hot_file = '../tests/data/hot_output/hot_web_application.yaml'
265         params = {'cpus': '2', 'context_root': 'my_web_app'}
266         self._test_successful_translation(tosca_file, hot_file, params)
267
268     def test_hot_translate_template_with_url_import(self):
269         tosca_file = '../tests/data/' \
270                      'tosca_single_instance_wordpress_with_url_import.yaml'
271         hot_file = '../tests/data/hot_output/' \
272                    'hot_single_instance_wordpress.yaml'
273         params = {'db_name': 'wordpress',
274                   'db_user': 'wp_user',
275                   'db_pwd': 'wp_pass',
276                   'db_root_pwd': 'passw0rd',
277                   'db_port': 3366,
278                   'cpus': 8}
279         self._test_successful_translation(tosca_file, hot_file, params)
280
281     def test_hot_translate_template_by_url_with_local_import(self):
282         tosca_file = 'https://raw.githubusercontent.com/openstack/' \
283                      'heat-translator/master/translator/tests/data/' \
284                      'tosca_single_instance_wordpress.yaml'
285         hot_file = '../tests/data/hot_output/' \
286                    'hot_single_instance_wordpress.yaml'
287         params = {'db_name': 'wordpress',
288                   'db_user': 'wp_user',
289                   'db_pwd': 'wp_pass',
290                   'db_root_pwd': 'passw0rd',
291                   'db_port': 3366,
292                   'cpus': 8}
293         self._test_successful_translation(tosca_file, hot_file, params)
294
295     def test_hot_translate_template_by_url_with_local_abspath_import(self):
296         tosca_file = 'https://raw.githubusercontent.com/openstack/' \
297                      'heat-translator/master/translator/tests/data/' \
298                      'tosca_single_instance_wordpress_with_local_abspath' \
299                      '_import.yaml'
300         hot_file = '../tests/data/hot_output/' \
301                    'hot_single_instance_wordpress.yaml'
302         params = {'db_name': 'wordpress',
303                   'db_user': 'wp_user',
304                   'db_pwd': 'wp_pass',
305                   'db_root_pwd': 'passw0rd',
306                   'db_port': 3366,
307                   'cpus': 8}
308         expected_msg = _('Absolute file name "/tmp/wordpress.yaml" cannot be '
309                          'used in a URL-based input template "https://raw.'
310                          'githubusercontent.com/openstack/heat-translator/'
311                          'master/translator/tests/data/tosca_single_instance_'
312                          'wordpress_with_local_abspath_import.yaml".')
313         msg_path = False
314         self._test_failed_translation(tosca_file, hot_file, params,
315                                       expected_msg, msg_path, ValidationError,
316                                       ImportError)
317
318     def test_hot_translate_template_by_url_with_url_import(self):
319         tosca_url = 'https://raw.githubusercontent.com/openstack/' \
320                     'heat-translator/master/translator/tests/data/' \
321                     'tosca_single_instance_wordpress_with_url_import.yaml'
322         hot_file = '../tests/data/hot_output/' \
323                    'hot_single_instance_wordpress.yaml'
324         params = {'db_name': 'wordpress',
325                   'db_user': 'wp_user',
326                   'db_pwd': 'wp_pass',
327                   'db_root_pwd': 'passw0rd',
328                   'db_port': 3366,
329                   'cpus': 8}
330         self._test_successful_translation(tosca_url, hot_file, params)
331
332     def test_translate_hello_world_csar(self):
333         tosca_file = '../tests/data/csar_hello_world.zip'
334         hot_file = '../tests/data/hot_output/hot_hello_world.yaml'
335         self._test_successful_translation(tosca_file, hot_file)
336
337     def test_translate_single_instance_wordpress_csar(self):
338         tosca_file = '../tests/data/csar_single_instance_wordpress.zip'
339         hot_file = '../tests/data/hot_output/' \
340                    'hot_single_instance_wordpress_from_csar.yaml'
341         params = {'db_name': 'wordpress',
342                   'db_user': 'wp_user',
343                   'db_pwd': 'wp_pass',
344                   'db_root_pwd': 'passw0rd',
345                   'db_port': 3366,
346                   'cpus': 8}
347         self._test_successful_translation(tosca_file, hot_file, params)
348
349     def test_translate_elk_csar_from_url(self):
350         tosca_file = 'https://github.com/openstack/heat-translator/raw/' \
351                      'master/translator/tests/data/csar_elk.zip'
352         hot_file = '../tests/data/hot_output/hot_elk_from_csar.yaml'
353         params = {'github_url':
354                   'http://github.com/paypal/rest-api-sample-app-nodejs.git',
355                   'my_cpus': 4}
356         self._test_successful_translation(tosca_file, hot_file, params)
357
358     def test_translate_csar_not_zip(self):
359         tosca_file = '../tests/data/csar_not_zip.zip'
360         hot_file = ''
361         params = {}
362         expected_msg = _('"%s" is not a valid zip file.')
363         msg_path = True
364         self._test_failed_translation(tosca_file, hot_file, params,
365                                       expected_msg, msg_path, ValidationError,
366                                       ValidationError)
367
368     def test_translate_csar_metadata_not_yaml(self):
369         tosca_file = '../tests/data/csar_metadata_not_yaml.zip'
370         hot_file = ''
371         params = {}
372         expected_msg = _('The file "TOSCA-Metadata/TOSCA.meta" in the CSAR '
373                          '"%s" does not contain valid YAML content.')
374         msg_path = True
375         self._test_failed_translation(tosca_file, hot_file, params,
376                                       expected_msg, msg_path, ValidationError,
377                                       ValidationError)
378
379     def test_translate_csar_wrong_metadata_file(self):
380         tosca_file = '../tests/data/csar_wrong_metadata_file.zip'
381         hot_file = ''
382         params = {}
383         expected_msg = _('"%s" is not a valid CSAR as it does not contain the '
384                          'required file "TOSCA.meta" in the folder '
385                          '"TOSCA-Metadata".')
386         msg_path = True
387         self._test_failed_translation(tosca_file, hot_file, params,
388                                       expected_msg, msg_path, ValidationError,
389                                       ValidationError)
390
391     def test_translate_csar_wordpress_invalid_import_path(self):
392         tosca_file = '../tests/data/csar_wordpress_invalid_import_path.zip'
393         hot_file = ''
394         params = {}
395         expected_msg = _('Import '
396                          '"Invalid_import_path/wordpress.yaml" is not valid.')
397         msg_path = False
398         self._test_failed_translation(tosca_file, hot_file, params,
399                                       expected_msg, msg_path, ValidationError,
400                                       ImportError)
401
402     def test_translate_csar_wordpress_invalid_script_url(self):
403         tosca_file = '../tests/data/csar_wordpress_invalid_script_url.zip'
404         hot_file = ''
405         params = {}
406         expected_msg = _('The resource at '
407                          '"https://raw.githubusercontent.com/openstack/'
408                          'heat-translator/master/translator/tests/data/'
409                          'custom_types/wordpress1.yaml" cannot be accessed.')
410         msg_path = False
411         self._test_failed_translation(tosca_file, hot_file, params,
412                                       expected_msg, msg_path, ValidationError,
413                                       URLException)
414
415     def test_hot_translate_flavor_image(self):
416         tosca_file = '../tests/data/test_tosca_flavor_and_image.yaml'
417         hot_file = '../tests/data/hot_output/hot_flavor_and_image.yaml'
418         self._test_successful_translation(tosca_file, hot_file)
419
420     def test_hot_translate_flavor_image_params(self):
421         tosca_file = '../tests/data/test_tosca_flavor_and_image.yaml'
422         hot_file = '../tests/data/hot_output/hot_flavor_and_image_params.yaml'
423         params = {'key_name': 'paramkey'}
424         self._test_successful_translation(tosca_file, hot_file, params)
425
426     def test_hot_translate_custom_type(self):
427         tosca_file = '../tests/data/test_tosca_custom_type.yaml'
428         hot_file = '../tests/data/hot_output/' \
429             'hot_custom_type.yaml'
430         params = {}
431         self._test_successful_translation(tosca_file, hot_file, params)
432
433     def test_hot_translate_custom_type_with_override(self):
434         tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
435         hot_file = '../tests/data/hot_output/' \
436             'hot_custom_type_with_override.yaml'
437         params = {}
438         self._test_successful_translation(tosca_file, hot_file, params)
439
440     def test_hot_translate_custom_type_with_param_override(self):
441         tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
442         hot_file = '../tests/data/hot_output/' \
443             'hot_custom_type_with_param_override.yaml'
444         params = {'install_path': '/home/custom/from/cli'}
445         self._test_successful_translation(tosca_file, hot_file, params)
446
447     def test_hot_translate_artifact(self):
448         tosca_file = '../tests/data/test_tosca_artifact.yaml'
449         hot_file = '../tests/data/hot_output/' \
450             'hot_artifact.yaml'
451         params = {}
452         self._test_successful_translation(tosca_file, hot_file, params)
453
454     def test_hot_translate_without_tosca_os_version(self):
455         tosca_file = '../tests/data/' \
456             'test_single_server_without_optional_version_prop.yaml'
457         hot_file = '../tests/data/hot_output/' \
458             'hot_single_server_without_tosca_os_version.yaml'
459         params = {}
460         self._test_successful_translation(tosca_file, hot_file, params)
461
462     def test_hot_translate_helloworld_with_userkey(self):
463         tosca_file = '../tests/data/tosca_helloworld.yaml'
464         hot_file = '../tests/data/hot_output/hot_hello_world_userkey.yaml'
465         params = {'key_name': 'userkey'}
466         self._test_successful_translation(tosca_file, hot_file, params)
467
468     def test_hot_translate_custom_networks_nodes_inline(self):
469         tosca_file = '../tests/data/network/' \
470                      'test_tosca_custom_network_nodes_inline.yaml'
471         hot_file = '../tests/data/hot_output/network/' \
472                    'hot_custom_network_nodes.yaml'
473         params = {}
474         self._test_successful_translation(tosca_file, hot_file, params)
475
476     def test_hot_translate_custom_networks_nodes_imports(self):
477         tosca_file = '../tests/data/network/' \
478                      'test_tosca_custom_network_nodes_imports.yaml'
479         hot_file = '../tests/data/hot_output/network/' \
480                    'hot_custom_network_nodes.yaml'
481         params = {}
482         self._test_successful_translation(tosca_file, hot_file, params)
483
484     def test_hot_translate_nfv_sample(self):
485         tosca_file = '../tests/data/nfv/test_tosca_nfv_sample.yaml'
486         hot_file = '../tests/data/hot_output/nfv/hot_nfv_sample.yaml'
487         params = {}
488         self._test_successful_translation(tosca_file, hot_file, params)
489
490     def test_hot_translate_policy(self):
491         tosca_file = '../tests/data/policies/tosca_policies.yaml'
492         hot_file = '../tests/data/hot_output/policies/hot_policies.yaml'
493         params = {}
494         self._test_successful_translation(tosca_file, hot_file, params)
495
496     def test_hot_script_types(self):
497         tosca_file = '../tests/data/interfaces/test_tosca_script_types.yaml'
498         hot_file = '../tests/data/hot_output/hot_script_types.yaml'
499         params = {}
500         self._test_successful_translation(tosca_file, hot_file, params)
501
502     def test_hot_interface_on_compute(self):
503         tosca_file = '../tests/data/interfaces/' \
504                      'test_tosca_interface_on_compute.yaml'
505         hot_file = '../tests/data/hot_output/interfaces/' \
506                    'hot_interface_on_compute.yaml'
507         params = {}
508         self._test_successful_translation(tosca_file, hot_file, params)
509
510     def test_hot_get_functions_semantic(self):
511         tosca_file = '../tests/data/test_tosca_get_functions_semantic.yaml'
512         hot_file = '../tests/data/hot_output/hot_get_functions_semantic.yaml'
513         params = {}
514         self._test_successful_translation(tosca_file, hot_file, params)
515
516     def test_hot_exchange_public_ssh_key(self):
517         tosca_file = '../tests/data/tosca_exchange_public_ssh_key.yaml'
518         hot_file = '../tests/data/hot_output/hot_exchange_public_ssh_key.yaml'
519         params = {}
520         self._test_successful_translation(tosca_file, hot_file, params)
521
522     def test_hot_translate_scaling_policy(self):
523         tosca_file = '../tests/data/autoscaling/tosca_autoscaling.yaml'
524         hot_files = [
525             '../tests/data/hot_output/autoscaling/hot_autoscaling.yaml',
526             '../tests/data/hot_output/autoscaling/asg_res.yaml',
527             ]
528         params = {}
529         self._test_successful_translation(tosca_file, hot_files, params)
530
531     def test_hot_translate_scaling_nested_plate(self):
532         tosca_file = '../tests/data/autoscaling/tosca_autoscaling.yaml'
533         hot_files = [
534             '../tests/data/hot_output/autoscaling/asg_res.yaml'
535         ]
536         params = {}
537         self._test_successful_translation(tosca_file, hot_files, params,
538                                           nested_resources=True)
539
540     def test_translate_unsupported_tosca_type(self):
541         tosca_file = '../tests/data/test_tosca_unsupported_type.yaml'
542         tosca_tpl = os.path.normpath(os.path.join(
543             os.path.dirname(os.path.abspath(__file__)), tosca_file))
544         params = {}
545         expected_msg = _('Type "tosca.nodes.LoadBalancer" is valid TOSCA '
546                          'type but translation support is not yet available.')
547         tosca = ToscaTemplate(tosca_tpl, params, True)
548         err = self.assertRaises(UnsupportedTypeError,
549                                 TOSCATranslator(tosca, params)
550                                 .translate)
551         self.assertEqual(expected_msg, err.__str__())
552
553     def test_hot_translate_cluster_scaling_policy(self):
554         tosca_file = '../tests/data/autoscaling/tosca_cluster_autoscaling.yaml'
555         hot_file = '../tests/data/hot_output/autoscaling/' \
556                    'hot_cluster_autoscaling.yaml'
557         params = {}
558         self._test_successful_translation(tosca_file, hot_file, params)
559
560     def test_hot_translate_nfv_scaling(self):
561         tosca_file = '../tests/data/nfv/test_tosca_nfv_autoscaling.yaml'
562         hot_files = [
563             '../tests/data/hot_output/nfv/hot_tosca_nfv_autoscaling.yaml',
564             '../tests/data/hot_output/nfv/SP1_res.yaml',
565             ]
566         params = {}
567         self._test_successful_translation(tosca_file, hot_files, params)
568
569     def test_hot_translate_mon_scaling_policy(self):
570         tosca_file = '../tests/data/monitoring/tosca_monitoring_scaling.yaml'
571         hot_files = [
572             '../tests/data/hot_output/monitoring/hot_monitoring_scaling.yaml',
573             '../tests/data/hot_output/monitoring/asg_res.yaml',
574         ]
575         params = {}
576         self._test_successful_translation(tosca_file, hot_files, params)