| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
import json |
| 14 |
import os |
| 15 |
|
| 16 |
from tempest.lib import exceptions |
| 17 |
import yaml |
| 18 |
|
| 19 |
from heatclient.tests.functional import base |
| 20 |
|
| 21 |
|
| 22 |
class SimpleReadOnlyHeatClientTest(base.ClientTestBase): |
| 23 |
"""Basic, read-only tests for Heat CLI client. |
| 24 |
|
| 25 |
Basic smoke test for the heat CLI commands which do not require |
| 26 |
creating or modifying stacks. |
| 27 |
""" |
| 28 |
|
| 29 |
def test_heat_fake_action(self): |
| 30 |
self.assertRaises(exceptions.CommandFailed, |
| 31 |
self.heat, |
| 32 |
'this-does-not-exist') |
| 33 |
|
| 34 |
def test_heat_stack_list(self): |
| 35 |
self.heat('stack-list') |
| 36 |
|
| 37 |
def test_heat_stack_list_debug(self): |
| 38 |
self.heat('stack-list', flags='--debug') |
| 39 |
|
| 40 |
def test_heat_resource_template_fmt_default(self): |
| 41 |
ret = self.heat('resource-template OS::Nova::Server') |
| 42 |
self.assertIn('Type: OS::Nova::Server', ret) |
| 43 |
|
| 44 |
def test_heat_resource_template_fmt_arg_short_yaml(self): |
| 45 |
ret = self.heat('resource-template -F yaml OS::Nova::Server') |
| 46 |
self.assertIn('Type: OS::Nova::Server', ret) |
| 47 |
self.assertIsInstance(yaml.safe_load(ret), dict) |
| 48 |
|
| 49 |
def test_heat_resource_template_fmt_arg_long_json(self): |
| 50 |
ret = self.heat('resource-template --format json OS::Nova::Server') |
| 51 |
self.assertIn('"Type": "OS::Nova::Server"', ret) |
| 52 |
self.assertIsInstance(json.loads(ret), dict) |
| 53 |
|
| 54 |
def test_heat_resource_type_list(self): |
| 55 |
ret = self.heat('resource-type-list') |
| 56 |
rsrc_types = self.parser.listing(ret) |
| 57 |
self.assertTableStruct(rsrc_types, ['resource_type']) |
| 58 |
|
| 59 |
def test_heat_resource_type_show(self): |
| 60 |
rsrc_schema = self.heat('resource-type-show OS::Heat::RandomString') |
| 61 |
|
| 62 |
self.assertIsInstance(json.loads(rsrc_schema), dict) |
| 63 |
|
| 64 |
def _template_validate(self, templ_name): |
| 65 |
heat_template_path = os.path.join( |
| 66 |
os.path.dirname(os.path.realpath(__file__)), |
| 67 |
'templates/%s' % templ_name) |
| 68 |
ret = self.heat('template-validate -f %s' % heat_template_path) |
| 69 |
|
| 70 |
|
| 71 |
self.assertIsInstance(json.loads(ret), dict) |
| 72 |
|
| 73 |
def test_heat_template_validate_yaml(self): |
| 74 |
self._template_validate('heat_minimal.yaml') |
| 75 |
|
| 76 |
def test_heat_template_validate_hot(self): |
| 77 |
self._template_validate('heat_minimal_hot.yaml') |
| 78 |
|
| 79 |
def test_heat_help(self): |
| 80 |
self.heat('help') |
| 81 |
|
| 82 |
def test_heat_bash_completion(self): |
| 83 |
self.heat('bash-completion') |
| 84 |
|
| 85 |
def test_heat_help_cmd(self): |
| 86 |
|
| 87 |
help_text = self.heat('help resource-template') |
| 88 |
lines = help_text.split('\n') |
| 89 |
self.assertFirstLineStartsWith(lines, 'usage: heat resource-template') |
| 90 |
|
| 91 |
def test_heat_version(self): |
| 92 |
self.heat('', flags='--version') |
| 93 |
|
| 94 |
def test_heat_template_version_list(self): |
| 95 |
ret = self.heat('template-version-list') |
| 96 |
tmpl_types = self.parser.listing(ret) |
| 97 |
self.assertTableStruct(tmpl_types, ['version', 'type']) |
| 98 |
|
| 99 |
def test_heat_template_function_list(self): |
| 100 |
ret = self.heat('template-function-list ' |
| 101 |
'heat_template_version.2013-05-23') |
| 102 |
tmpl_functions = self.parser.listing(ret) |
| 103 |
self.assertTableStruct(tmpl_functions, ['functions', 'description']) |