blob: dfc9c4f021d37cbf2308c4c05787b93dac34320e [file] [log] [blame]
sabeensyedabf97892015-10-21 18:20:48 +00001# 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
14from heat_integrationtests.functional import functional_base
15
16
17class TemplateAPITest(functional_base.FunctionalTestsBase):
18 """This will test the following template calls:
19
20 1. Get the template content for the specific stack
21 2. List template versions
22 3. List resource types
23 4. Show resource details for OS::Heat::TestResource
24 """
25
26 template = {
27 'heat_template_version': '2014-10-16',
28 'description': 'Test Template APIs',
29 'resources': {
30 'test1': {
31 'type': 'OS::Heat::TestResource',
32 'properties': {
33 'update_replace': False,
34 'wait_secs': 0,
35 'value': 'Test1',
36 'fail': False,
37 }
38 }
39 }
40 }
41
42 def setUp(self):
43 super(TemplateAPITest, self).setUp()
44
45 def test_get_stack_template(self):
46 stack_identifier = self.stack_create(
47 template=self.template
48 )
49 template_from_client = self.client.stacks.template(stack_identifier)
50 self.assertDictEqual(self.template, template_from_client)
51
52 def test_template_version(self):
53 template_versions = self.client.template_versions.list()
54 supported_template_versions = ["2013-05-23", "2014-10-16",
55 "2015-04-30", "2015-10-15",
56 "2012-12-12", "2010-09-09",
57 "2016-04-08"]
58 for template in template_versions:
59 self.assertIn(template.version.split(".")[1],
60 supported_template_versions)
61
62 def test_resource_types(self):
63 resource_types = self.client.resource_types.list()
64 self.assertTrue(any(resource.resource_type == "OS::Heat::TestResource"
65 for resource in resource_types))
66
67 def test_show_resource_template(self):
68 resource_details = self.client.resource_types.get(
69 resource_type="OS::Heat::TestResource"
70 )
71 self.assertEqual("OS::Heat::TestResource",
72 resource_details['resource_type'])