sabeensyed | abf9789 | 2015-10-21 18:20:48 +0000 | [diff] [blame] | 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 | |
| 14 | from heat_integrationtests.functional import functional_base |
| 15 | |
| 16 | |
| 17 | class 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 | |
sabeensyed | abf9789 | 2015-10-21 18:20:48 +0000 | [diff] [blame] | 42 | def test_get_stack_template(self): |
| 43 | stack_identifier = self.stack_create( |
| 44 | template=self.template |
| 45 | ) |
| 46 | template_from_client = self.client.stacks.template(stack_identifier) |
shizhihui | 1d76d5c | 2016-07-27 09:47:29 +0800 | [diff] [blame] | 47 | self.assertEqual(self.template, template_from_client) |
sabeensyed | abf9789 | 2015-10-21 18:20:48 +0000 | [diff] [blame] | 48 | |
| 49 | def test_template_version(self): |
| 50 | template_versions = self.client.template_versions.list() |
| 51 | supported_template_versions = ["2013-05-23", "2014-10-16", |
| 52 | "2015-04-30", "2015-10-15", |
| 53 | "2012-12-12", "2010-09-09", |
ricolin | 62c6360 | 2016-09-21 15:23:10 +0800 | [diff] [blame] | 54 | "2016-04-08", "2016-10-14", "newton", |
Zane Bitter | 1f50469 | 2017-03-14 15:34:31 -0400 | [diff] [blame] | 55 | "2017-02-24", "ocata", |
| 56 | "2017-09-01", "pike"] |
sabeensyed | abf9789 | 2015-10-21 18:20:48 +0000 | [diff] [blame] | 57 | for template in template_versions: |
| 58 | self.assertIn(template.version.split(".")[1], |
| 59 | supported_template_versions) |
| 60 | |
| 61 | def test_resource_types(self): |
| 62 | resource_types = self.client.resource_types.list() |
| 63 | self.assertTrue(any(resource.resource_type == "OS::Heat::TestResource" |
| 64 | for resource in resource_types)) |
| 65 | |
| 66 | def test_show_resource_template(self): |
| 67 | resource_details = self.client.resource_types.get( |
| 68 | resource_type="OS::Heat::TestResource" |
| 69 | ) |
| 70 | self.assertEqual("OS::Heat::TestResource", |
| 71 | resource_details['resource_type']) |