Update tosca lib to version 0.5
[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.utils.gettextutils import _
20 from translator.common.utils import TranslationUtils
21 from translator.tests.base import TestCase
22
23
24 class ToscaHotTranslationTest(TestCase):
25
26     def test_hot_translate_single_server(self):
27         tosca_file = '../tests/data/tosca_single_server.yaml'
28         hot_file = '../tests/data/hot_output/hot_single_server.yaml'
29         params = {'cpus': 1}
30         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
31                                                                    hot_file,
32                                                                    params)
33         self.assertEqual({}, diff, '<difference> : ' +
34                          json.dumps(diff, indent=4, separators=(', ', ': ')))
35
36     def test_hot_translate_single_server_with_defaults(self):
37         tosca_file = \
38             '../tests/data/tosca_single_server_with_defaults.yaml'
39         hot_file_with_input = '../tests/data/hot_output/' \
40             'hot_single_server_with_defaults_with_input.yaml'
41         hot_file_without_input = '../tests/data/hot_output/' \
42             'hot_single_server_with_defaults_without_input.yaml'
43
44         params1 = {'cpus': '1'}
45         diff1 = TranslationUtils.compare_tosca_translation_with_hot(
46             tosca_file, hot_file_with_input, params1)
47         self.assertEqual({}, diff1, '<difference> : ' +
48                          json.dumps(diff1, indent=4, separators=(', ', ': ')))
49
50         params2 = {}
51         diff2 = TranslationUtils.compare_tosca_translation_with_hot(
52             tosca_file, hot_file_without_input, params2)
53         self.assertEqual({}, diff2, '<difference> : ' +
54                          json.dumps(diff2, indent=4, separators=(', ', ': ')))
55
56     def test_hot_translate_wordpress_single_instance(self):
57         tosca_file = '../tests/data/tosca_single_instance_wordpress.yaml'
58         hot_file = '../tests/data/hot_output/' \
59             'hot_single_instance_wordpress.yaml'
60         params = {'db_name': 'wordpress',
61                   'db_user': 'wp_user',
62                   'db_pwd': 'wp_pass',
63                   'db_root_pwd': 'passw0rd',
64                   'db_port': 3366,
65                   'cpus': 8}
66         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
67                                                                    hot_file,
68                                                                    params)
69         self.assertEqual({}, diff, '<difference> : ' +
70                          json.dumps(diff, indent=4, separators=(', ', ': ')))
71
72     def test_hot_translate_helloworld(self):
73         tosca_file = '../tests/data/tosca_helloworld.yaml'
74         hot_file = '../tests/data/hot_output/hot_hello_world.yaml'
75         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
76                                                                    hot_file,
77                                                                    {})
78         self.assertEqual({}, diff, '<difference> : ' +
79                          json.dumps(diff, indent=4, separators=(', ', ': ')))
80
81     def test_hot_translate_host_assignment(self):
82         tosca_file = '../tests/data/test_host_assignment.yaml'
83         hot_file = '../tests/data/hot_output/hot_host_assignment.yaml'
84         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
85                                                                    hot_file,
86                                                                    {})
87         self.assertEqual({}, diff, '<difference> : ' +
88                          json.dumps(diff, indent=4, separators=(', ', ': ')))
89
90     def test_hot_translate_elk(self):
91         tosca_file = '../tests/data/tosca_elk.yaml'
92         hot_file = '../tests/data/hot_output/hot_elk.yaml'
93         params = {'github_url':
94                   'http://github.com/paypal/rest-api-sample-app-nodejs.git',
95                   'my_cpus': 4}
96         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
97                                                                    hot_file,
98                                                                    params)
99         self.assertEqual({}, diff, '<difference> : ' +
100                          json.dumps(diff, indent=4, separators=(', ', ': ')))
101
102     def test_hot_translate_nodejs_mongodb_two_instances(self):
103         tosca_file = '../tests/data/tosca_nodejs_mongodb_two_instances.yaml'
104         hot_file = '../tests/data/hot_output/' \
105                    'hot_nodejs_mongodb_two_instances.yaml'
106         params = {'github_url':
107                   'http://github.com/paypal/rest-api-sample-app-nodejs.git',
108                   'my_cpus': 4}
109         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
110                                                                    hot_file,
111                                                                    params)
112         self.assertEqual({}, diff, '<difference> : ' +
113                          json.dumps(diff, indent=4, separators=(', ', ': ')))
114
115     def test_hot_translate_blockstorage_with_attachment(self):
116         tosca_file = '../tests/data/storage/' \
117                      'tosca_blockstorage_with_attachment.yaml'
118         hot_file = '../tests/data/hot_output/storage/' \
119                    'hot_blockstorage_with_attachment.yaml'
120         params = {'cpus': 1,
121                   'storage_location': '/dev/vdc',
122                   'storage_size': '2000 MB',
123                   'storage_snapshot_id': 'ssid'}
124         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
125                                                                    hot_file,
126                                                                    params)
127         self.assertEqual({}, diff, '<difference> : ' +
128                          json.dumps(diff, indent=4, separators=(', ', ': ')))
129
130     def test_hot_translate_blockstorage_with_custom_relationship_type(self):
131         tosca_file = '../tests/data/storage/' \
132                      'tosca_blockstorage_with_custom_relationship_type.yaml'
133         hot_file = '../tests/data/hot_output/storage/' \
134                    'hot_blockstorage_with_custom_relationship_type.yaml'
135         params = {'cpus': 1,
136                   'storage_location': '/dev/vdc',
137                   'storage_size': '1 GB',
138                   'storage_snapshot_id': 'ssid'}
139         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
140                                                                    hot_file,
141                                                                    params)
142         self.assertEqual({}, diff, '<difference> : ' +
143                          json.dumps(diff, indent=4, separators=(', ', ': ')))
144
145     def test_hot_translate_blockstorage_with_relationship_template(self):
146         tosca_file = '../tests/data/storage/' \
147                      'tosca_blockstorage_with_relationship_template.yaml'
148         hot_file = '../tests/data/hot_output/storage/' \
149                    'hot_blockstorage_with_relationship_template.yaml'
150         params = {'cpus': 1,
151                   'storage_location': '/dev/vdc',
152                   'storage_size': '1 GB'}
153         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
154                                                                    hot_file,
155                                                                    params)
156         self.assertEqual({}, diff, '<difference> : ' +
157                          json.dumps(diff, indent=4, separators=(', ', ': ')))
158
159     def test_hot_translate_blockstorage_with_attachment_notation1(self):
160         tosca_file = '../tests/data/storage/' \
161                      'tosca_blockstorage_with_attachment_notation1.yaml'
162         hot_file1 = '../tests/data/hot_output/storage/' \
163                     'hot_blockstorage_with_attachment_notation1_alt1.yaml'
164         hot_file2 = '../tests/data/hot_output/storage/' \
165                     'hot_blockstorage_with_attachment_notation1_alt2.yaml'
166         params = {'cpus': 1,
167                   'storage_location': 'some_folder',
168                   'storage_size': '1 GB',
169                   'storage_snapshot_id': 'ssid'}
170         diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
171                                                                     hot_file1,
172                                                                     params)
173         try:
174             self.assertEqual({}, diff1, '<difference> : ' +
175                              json.dumps(diff1, indent=4,
176                                         separators=(', ', ': ')))
177         except Exception:
178             diff2 = TranslationUtils.compare_tosca_translation_with_hot(
179                 tosca_file, hot_file2, params)
180             self.assertEqual({}, diff2, '<difference> : ' +
181                              json.dumps(diff2, indent=4,
182                                         separators=(', ', ': ')))
183
184     def test_hot_translate_blockstorage_with_attachment_notation2(self):
185         tosca_file = '../tests/data/storage/' \
186                      'tosca_blockstorage_with_attachment_notation2.yaml'
187         hot_file1 = '../tests/data/hot_output/storage/' \
188                     'hot_blockstorage_with_attachment_notation2_alt1.yaml'
189         hot_file2 = '../tests/data/hot_output/storage/' \
190                     'hot_blockstorage_with_attachment_notation2_alt2.yaml'
191         params = {'cpus': 1,
192                   'storage_location': '/dev/vdc',
193                   'storage_size': '1 GB',
194                   'storage_snapshot_id': 'ssid'}
195         diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
196                                                                     hot_file1,
197                                                                     params)
198         try:
199             self.assertEqual({}, diff1, '<difference> : ' +
200                              json.dumps(diff1, indent=4,
201                                         separators=(', ', ': ')))
202         except Exception:
203             diff2 = TranslationUtils.compare_tosca_translation_with_hot(
204                 tosca_file, hot_file2, params)
205             self.assertEqual({}, diff2, '<difference> : ' +
206                              json.dumps(diff2, indent=4,
207                                         separators=(', ', ': ')))
208
209     def test_hot_translate_multiple_blockstorage_with_attachment(self):
210         tosca_file = '../tests/data/storage/' \
211                      'tosca_multiple_blockstorage_with_attachment.yaml'
212         hot_file1 = '../tests/data/hot_output/storage/' \
213                     'hot_multiple_blockstorage_with_attachment_alt1.yaml'
214         hot_file2 = '../tests/data/hot_output/storage/' \
215                     'hot_multiple_blockstorage_with_attachment_alt2.yaml'
216         params = {'cpus': 1,
217                   'storage_location': '/dev/vdc',
218                   'storage_size': '1 GB',
219                   'storage_snapshot_id': 'ssid'}
220         diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
221                                                                     hot_file1,
222                                                                     params)
223         try:
224             self.assertEqual({}, diff1, '<difference> : ' +
225                              json.dumps(diff1, indent=4,
226                                         separators=(', ', ': ')))
227         except Exception:
228             diff2 = TranslationUtils.compare_tosca_translation_with_hot(
229                 tosca_file, hot_file2, params)
230             self.assertEqual({}, diff2, '<difference> : ' +
231                              json.dumps(diff2, indent=4,
232                                         separators=(', ', ': ')))
233
234     def test_hot_translate_single_object_store(self):
235         tosca_file = '../tests/data/storage/tosca_single_object_store.yaml'
236         hot_file = '../tests/data/hot_output/hot_single_object_store.yaml'
237         params = {'objectstore_name': 'myobjstore'}
238         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
239                                                                    hot_file,
240                                                                    params)
241         self.assertEqual({}, diff, '<difference> : ' +
242                          json.dumps(diff, indent=4, separators=(', ', ': ')))
243
244     def test_hot_translate_one_server_one_network(self):
245         tosca_file = '../tests/data/network/tosca_one_server_one_network.yaml'
246         hot_file = '../tests/data/hot_output/network/' \
247                    'hot_one_server_one_network.yaml'
248         params = {'network_name': 'private_net'}
249         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
250                                                                    hot_file,
251                                                                    params)
252         self.assertEqual({}, diff, '<difference> : ' +
253                          json.dumps(diff, indent=4, separators=(', ', ': ')))
254
255     def test_hot_translate_server_on_existing_network(self):
256         tosca_file = '../tests/data/network/' \
257                      'tosca_server_on_existing_network.yaml'
258         hot_file = '../tests/data/hot_output/network/' \
259                    'hot_server_on_existing_network.yaml'
260         params = {'network_name': 'private_net'}
261         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
262                                                                    hot_file,
263                                                                    params)
264         self.assertEqual({}, diff, '<difference> : ' +
265                          json.dumps(diff, indent=4, separators=(', ', ': ')))
266
267     def test_hot_translate_two_servers_one_network(self):
268         tosca_file = '../tests/data/network/tosca_two_servers_one_network.yaml'
269         hot_file = '../tests/data/hot_output/network/' \
270                    'hot_two_servers_one_network.yaml'
271         params = {'network_name': 'my_private_net',
272                   'network_cidr': '10.0.0.0/24',
273                   'network_start_ip': '10.0.0.100',
274                   'network_end_ip': '10.0.0.150'}
275         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
276                                                                    hot_file,
277                                                                    params)
278         self.assertEqual({}, diff, '<difference> : ' +
279                          json.dumps(diff, indent=4, separators=(', ', ': ')))
280
281     def test_hot_translate_one_server_three_networks(self):
282         tosca_file = '../tests/data/network/' \
283                      'tosca_one_server_three_networks.yaml'
284         hot_file = '../tests/data/hot_output/network/' \
285                    'hot_one_server_three_networks.yaml'
286         params = {}
287         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
288                                                                    hot_file,
289                                                                    params)
290         self.assertEqual({}, diff, '<difference> : ' +
291                          json.dumps(diff, indent=4, separators=(', ', ': ')))
292
293     def test_hot_translate_software_component(self):
294         tosca_file = '../tests/data/tosca_software_component.yaml'
295         hot_file = '../tests/data/hot_output/hot_software_component.yaml'
296         params = {'cpus': '1',
297                   'download_url': 'http://www.software.com/download'}
298         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
299                                                                    hot_file,
300                                                                    params)
301         self.assertEqual({}, diff, '<difference> : ' +
302                          json.dumps(diff, indent=4, separators=(', ', ': ')))
303
304     def test_hot_translate_web_application(self):
305         tosca_file = '../tests/data/tosca_web_application.yaml'
306         hot_file = '../tests/data/hot_output/hot_web_application.yaml'
307         params = {'cpus': '2', 'context_root': 'my_web_app'}
308         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
309                                                                    hot_file,
310                                                                    params)
311         self.assertEqual({}, diff, '<difference> : ' +
312                          json.dumps(diff, indent=4, separators=(', ', ': ')))
313
314     def test_hot_translate_template_with_url_import(self):
315         tosca_file = '../tests/data/' \
316                      'tosca_single_instance_wordpress_with_url_import.yaml'
317         hot_file = '../tests/data/hot_output/' \
318                    'hot_single_instance_wordpress.yaml'
319         params = {'db_name': 'wordpress',
320                   'db_user': 'wp_user',
321                   'db_pwd': 'wp_pass',
322                   'db_root_pwd': 'passw0rd',
323                   'db_port': 3366,
324                   'cpus': 8}
325         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
326                                                                    hot_file,
327                                                                    params)
328         self.assertEqual({}, diff, '<difference> : ' +
329                          json.dumps(diff, indent=4, separators=(', ', ': ')))
330
331     def test_hot_translate_template_by_url_with_local_import(self):
332         tosca_file = 'https://raw.githubusercontent.com/openstack/' \
333                      'heat-translator/master/translator/tests/data/' \
334                      'tosca_single_instance_wordpress.yaml'
335         hot_file = '../tests/data/hot_output/' \
336                    'hot_single_instance_wordpress.yaml'
337         params = {'db_name': 'wordpress',
338                   'db_user': 'wp_user',
339                   'db_pwd': 'wp_pass',
340                   'db_root_pwd': 'passw0rd',
341                   'db_port': 3366,
342                   'cpus': 8}
343         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
344                                                                    hot_file,
345                                                                    params)
346         self.assertEqual({}, diff, '<difference> : ' +
347                          json.dumps(diff, indent=4, separators=(', ', ': ')))
348
349     def test_hot_translate_template_by_url_with_local_abspath_import(self):
350         tosca_file = 'https://raw.githubusercontent.com/openstack/' \
351                      'heat-translator/master/translator/tests/data/' \
352                      'tosca_single_instance_wordpress_with_local_abspath' \
353                      '_import.yaml'
354         hot_file = '../tests/data/hot_output/' \
355                    'hot_single_instance_wordpress.yaml'
356         params = {'db_name': 'wordpress',
357                   'db_user': 'wp_user',
358                   'db_pwd': 'wp_pass',
359                   'db_root_pwd': 'passw0rd',
360                   'db_port': 3366,
361                   'cpus': 8}
362
363         self.assertRaises(
364             ValidationError,
365             TranslationUtils.compare_tosca_translation_with_hot,
366             tosca_file, hot_file, params)
367         expected_msg = _('Absolute file name "/tmp/wordpress.yaml" cannot be '
368                          'used in a URL-based input template "https://raw.'
369                          'githubusercontent.com/openstack/heat-translator/'
370                          'master/translator/tests/data/tosca_single_instance_'
371                          'wordpress_with_local_abspath_import.yaml".')
372         ExceptionCollector.assertExceptionMessage(ImportError, expected_msg)
373
374     def test_hot_translate_template_by_url_with_url_import(self):
375         tosca_url = 'https://raw.githubusercontent.com/openstack/' \
376                     'heat-translator/master/translator/tests/data/' \
377                     'tosca_single_instance_wordpress_with_url_import.yaml'
378         hot_file = '../tests/data/hot_output/' \
379                    'hot_single_instance_wordpress.yaml'
380         params = {'db_name': 'wordpress',
381                   'db_user': 'wp_user',
382                   'db_pwd': 'wp_pass',
383                   'db_root_pwd': 'passw0rd',
384                   'db_port': 3366,
385                   'cpus': 8}
386         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_url,
387                                                                    hot_file,
388                                                                    params)
389         self.assertEqual({}, diff, '<difference> : ' +
390                          json.dumps(diff, indent=4, separators=(', ', ': ')))
391
392     def test_translate_hello_world_csar(self):
393         tosca_file = '../tests/data/csar_hello_world.zip'
394         hot_file = '../tests/data/hot_output/hot_hello_world.yaml'
395         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
396                                                                    hot_file,
397                                                                    {})
398         self.assertEqual({}, diff, '<difference> : ' +
399                          json.dumps(diff, indent=4, separators=(', ', ': ')))
400
401     def test_translate_single_instance_wordpress_csar(self):
402         tosca_file = '../tests/data/csar_single_instance_wordpress.zip'
403         hot_file = '../tests/data/hot_output/' \
404                    'hot_single_instance_wordpress_from_csar.yaml'
405         params = {'db_name': 'wordpress',
406                   'db_user': 'wp_user',
407                   'db_pwd': 'wp_pass',
408                   'db_root_pwd': 'passw0rd',
409                   'db_port': 3366,
410                   'cpus': 8}
411         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
412                                                                    hot_file,
413                                                                    params)
414         self.assertEqual({}, diff, '<difference> : ' +
415                          json.dumps(diff, indent=4, separators=(', ', ': ')))
416
417     def test_translate_elk_csar_from_url(self):
418         tosca_file = 'https://github.com/openstack/heat-translator/raw/' \
419                      'master/translator/tests/data/csar_elk.zip'
420         hot_file = '../tests/data/hot_output/hot_elk_from_csar.yaml'
421         params = {'github_url':
422                   'http://github.com/paypal/rest-api-sample-app-nodejs.git',
423                   'my_cpus': 4}
424         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
425                                                                    hot_file,
426                                                                    params)
427         self.assertEqual({}, diff, '<difference> : ' +
428                          json.dumps(diff, indent=4, separators=(', ', ': ')))
429
430     def test_translate_csar_not_zip(self):
431         tosca_file = '../tests/data/csar_not_zip.zip'
432         hot_file = ''
433         params = {}
434
435         self.assertRaises(
436             ValidationError,
437             TranslationUtils.compare_tosca_translation_with_hot,
438             tosca_file, hot_file, params)
439         path = os.path.normpath(os.path.join(
440             os.path.dirname(os.path.realpath(__file__)), tosca_file))
441         expected_msg = _('"%s" is not a valid zip file.') % path
442         ExceptionCollector.assertExceptionMessage(ValidationError,
443                                                   expected_msg)
444
445     def test_translate_csar_metadata_not_yaml(self):
446         tosca_file = '../tests/data/csar_metadata_not_yaml.zip'
447         hot_file = ''
448         params = {}
449
450         self.assertRaises(
451             ValidationError,
452             TranslationUtils.compare_tosca_translation_with_hot,
453             tosca_file, hot_file, params)
454         path = os.path.normpath(os.path.join(
455             os.path.dirname(os.path.realpath(__file__)), tosca_file))
456         expected_msg = _('The file "TOSCA-Metadata/TOSCA.meta" in the CSAR '
457                          '"%s" does not contain valid YAML content.') % path
458         ExceptionCollector.assertExceptionMessage(ValidationError,
459                                                   expected_msg)
460
461     def test_translate_csar_wrong_metadata_file(self):
462         tosca_file = '../tests/data/csar_wrong_metadata_file.zip'
463         hot_file = ''
464         params = {}
465
466         self.assertRaises(
467             ValidationError,
468             TranslationUtils.compare_tosca_translation_with_hot,
469             tosca_file, hot_file, params)
470         path = os.path.normpath(os.path.join(
471             os.path.dirname(os.path.realpath(__file__)), tosca_file))
472         expected_msg = _('"%s" is not a valid CSAR as it does not contain the '
473                          'required file "TOSCA.meta" in the folder '
474                          '"TOSCA-Metadata".') % path
475         ExceptionCollector.assertExceptionMessage(ValidationError,
476                                                   expected_msg)
477
478     def test_translate_csar_wordpress_invalid_import_path(self):
479         tosca_file = '../tests/data/csar_wordpress_invalid_import_path.zip'
480         hot_file = ''
481         params = {}
482
483         self.assertRaises(
484             ValidationError,
485             TranslationUtils.compare_tosca_translation_with_hot,
486             tosca_file, hot_file, params)
487         expected_msg = _('Import '
488                          '"Invalid_import_path/wordpress.yaml" is not valid.')
489         ExceptionCollector.assertExceptionMessage(ImportError, expected_msg)
490
491     def test_translate_csar_wordpress_invalid_script_url(self):
492         tosca_file = '../tests/data/csar_wordpress_invalid_script_url.zip'
493         hot_file = ''
494         params = {}
495
496         self.assertRaises(
497             ValidationError,
498             TranslationUtils.compare_tosca_translation_with_hot,
499             tosca_file, hot_file, params)
500         expected_msg = _('The resource at '
501                          '"https://raw.githubusercontent.com/openstack/'
502                          'heat-translator/master/translator/tests/data/'
503                          'custom_types/wordpress1.yaml" cannot be accessed.')
504         ExceptionCollector.assertExceptionMessage(URLException, expected_msg)
505
506     def test_hot_translate_flavor_image(self):
507         tosca_file = '../tests/data/test_tosca_flavor_and_image.yaml'
508         hot_file = '../tests/data/hot_output/hot_flavor_and_image.yaml'
509         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
510                                                                    hot_file,
511                                                                    {})
512         self.assertEqual({}, diff, '<difference> : ' +
513                          json.dumps(diff, indent=4, separators=(', ', ': ')))
514
515     def test_hot_translate_flavor_image_params(self):
516         tosca_file = '../tests/data/test_tosca_flavor_and_image.yaml'
517         hot_file = '../tests/data/hot_output/hot_flavor_and_image_params.yaml'
518         params = {'key_name': 'paramkey'}
519         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
520                                                                    hot_file,
521                                                                    params)
522         self.assertEqual({}, diff, '<difference> : ' +
523                          json.dumps(diff, indent=4, separators=(', ', ': ')))
524
525     def test_hot_translate_custom_type(self):
526         tosca_file = '../tests/data/test_tosca_custom_type.yaml'
527         hot_file = '../tests/data/hot_output/' \
528             'hot_custom_type.yaml'
529         params = {}
530         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
531                                                                    hot_file,
532                                                                    params)
533         self.assertEqual({}, diff, '<difference> : ' +
534                          json.dumps(diff, indent=4, separators=(', ', ': ')))
535
536     def test_hot_translate_custom_type_with_override(self):
537         tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
538         hot_file = '../tests/data/hot_output/' \
539             'hot_custom_type_with_override.yaml'
540         params = {}
541         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
542                                                                    hot_file,
543                                                                    params)
544         self.assertEqual({}, diff, '<difference> : ' +
545                          json.dumps(diff, indent=4, separators=(', ', ': ')))
546
547     def test_hot_translate_custom_type_with_param_override(self):
548         tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
549         hot_file = '../tests/data/hot_output/' \
550             'hot_custom_type_with_param_override.yaml'
551         params = {'install_path': '/home/custom/from/cli'}
552         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
553                                                                    hot_file,
554                                                                    params)
555         self.assertEqual({}, diff, '<difference> : ' +
556                          json.dumps(diff, indent=4, separators=(', ', ': ')))
557
558     def test_hot_translate_artifact(self):
559         tosca_file = '../tests/data/test_tosca_artifact.yaml'
560         hot_file = '../tests/data/hot_output/' \
561             'hot_artifact.yaml'
562         params = {}
563         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
564                                                                    hot_file,
565                                                                    params)
566         self.assertEqual({}, diff, '<difference> : ' +
567                          json.dumps(diff, indent=4, separators=(', ', ': ')))
568
569     def test_hot_translate_without_tosca_os_version(self):
570         tosca_file = '../tests/data/' \
571             'test_single_server_without_optional_version_prop.yaml'
572         hot_file = '../tests/data/hot_output/' \
573             'hot_single_server_without_tosca_os_version.yaml'
574         params = {}
575         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
576                                                                    hot_file,
577                                                                    params)
578         self.assertEqual({}, diff, '<difference> : ' +
579                          json.dumps(diff, indent=4, separators=(', ', ': ')))
580
581     def test_hot_translate_helloworld_with_userkey(self):
582         tosca_file = '../tests/data/tosca_helloworld.yaml'
583         hot_file = '../tests/data/hot_output/hot_hello_world_userkey.yaml'
584         params = {'key_name': 'userkey'}
585         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
586                                                                    hot_file,
587                                                                    params)
588         self.assertEqual({}, diff, '<difference> : ' +
589                          json.dumps(diff, indent=4, separators=(', ', ': ')))
590
591     def test_hot_translate_custom_networks_nodes_inline(self):
592         tosca_file = '../tests/data/network/' \
593                      'test_tosca_custom_network_nodes_inline.yaml'
594         hot_file = '../tests/data/hot_output/network/' \
595                    'hot_custom_network_nodes.yaml'
596         params = {}
597         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
598                                                                    hot_file,
599                                                                    params)
600         self.assertEqual({}, diff, '<difference> : ' +
601                          json.dumps(diff, indent=4, separators=(', ', ': ')))
602
603     def test_hot_translate_custom_networks_nodes_imports(self):
604         tosca_file = '../tests/data/network/' \
605                      'test_tosca_custom_network_nodes_imports.yaml'
606         hot_file = '../tests/data/hot_output/network/' \
607                    'hot_custom_network_nodes.yaml'
608         params = {}
609         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
610                                                                    hot_file,
611                                                                    params)
612         self.assertEqual({}, diff, '<difference> : ' +
613                          json.dumps(diff, indent=4, separators=(', ', ': ')))
614
615     def test_hot_translate_nfv_sample(self):
616         tosca_file = '../tests/data/test_tosca_nfv_sample.yaml'
617         hot_file = '../tests/data/hot_output/hot_nfv_sample.yaml'
618         params = {}
619         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
620                                                                    hot_file,
621                                                                    params)
622         self.assertEqual({}, diff, '<difference> : ' +
623                          json.dumps(diff, indent=4, separators=(', ', ': ')))
624
625     def test_hot_translate_policy(self):
626         tosca_file = '../tests/data/tosca_policies.yaml'
627         hot_file = '../tests/data/hot_output/hot_policies.yaml'
628         params = {}
629         diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
630                                                                    hot_file,
631                                                                    params)
632         self.assertEqual({}, diff, '<difference> : ' +
633                          json.dumps(diff, indent=4, separators=(', ', ': ')))