summaryrefslogtreecommitdiffstats
path: root/tosca2heat/heat-translator/translator/tests/test_shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/heat-translator/translator/tests/test_shell.py')
-rw-r--r--tosca2heat/heat-translator/translator/tests/test_shell.py54
1 files changed, 24 insertions, 30 deletions
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',