diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2016-04-07 14:08:49 -0400 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2016-04-07 14:59:30 -0400 |
commit | c8201c119ec686e79797721156767685fe848aca (patch) | |
tree | cce6aa15ded38d89c18a14b76c21f21e0b1a24f7 /tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py | |
parent | 4e4c86a06d58b1816c074c7f9da4c58bbf10368c (diff) |
Update tosca lib to version 0.5
Use tosca-parser and heat-translator to analyze to the basic
nfv-tosca type definitions, and use simple tosca new feature
such as policy, group and trigger, which are now supported by
the latest version of tosca-parser and heat-translator.
JIRA:PARSER-18
Change-Id: I797bcacbb5b32005d0aeb0f3f32851ac96e30f01
Signed--off-by: shangxdy <shang.xiaodong@zte.com.cn>
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py')
-rw-r--r-- | tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py b/tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py deleted file mode 100644 index abe8f5e..0000000 --- a/tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py +++ /dev/null @@ -1,116 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os -import shutil -import tempfile - -from toscaparser.common import exception -from toscaparser.utils.gettextutils import _ -import translator.shell as shell -from translator.tests.base import TestCase - - -class ShellTest(TestCase): - tosca_helloworld = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "data/tosca_helloworld.yaml") - template_file = '--template-file=' + tosca_helloworld - template_type = '--template-type=tosca' - template_validation = "--validate-only=true" - 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', - self.template_type)) - err_msg = _('The path template.txt is not a valid file or URL.') - 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)) - - 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)) - - def test_valid_template(self): - try: - shell.main([self.template_file, self.template_type]) - 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__)), - "data/tosca_single_instance_wordpress.yaml") - parameters = '--parameters="cpus=2;db_name=wpdb;db_user=test;'\ - 'db_port=2000;db_root_pwd=fun2test;db_pwd=fun2test"' - template = '--template-file=' + tosca_single_instance_wordpress - try: - shell.main([template, self.template_type, parameters]) - except Exception: - self.fail(self.failure_msg) - - def test_validate_only(self): - try: - shell.main([self.template_file, self.template_type, - self.template_validation]) - except Exception: - self.fail(self.failure_msg) - - template = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "data/tosca_helloworld_invalid.yaml") - invalid_template = '--template-file=' + template - self.assertRaises(exception.ValidationError, shell.main, - [invalid_template, self.template_type, - self.template_validation]) - - def test_output_file(self): - temp_dir = tempfile.mkdtemp() - temp_file = "/test_translation_output.txt" - output_file = "--output-file=" + temp_dir + temp_file - try: - shell.main([self.template_file, self.template_type, output_file]) - except Exception: - self.fail(self.failure_msg) - finally: - if temp_dir: - shutil.rmtree(temp_dir) - self.assertTrue(temp_dir is None or - not os.path.exists(temp_dir)) |