Debian Codegraph @

heatclient/tests/unit/test_template_versions.py

raw symbols SCIP
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
3 # not use this file except in compliance with the License. You may obtain
4 # a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations
12 # under the License.
13
14 import testtools
15
16 from heatclient.v1 import template_versions
17
18
19 class TemplateVersionManagerTest(testtools.TestCase):
20
21 def setUp(self):
22 super().setUp()
23
24 def test_list_versions(self):
25 expect = ('GET', '/template_versions')
26
27 class FakeResponse:
28 def json(self):
29 return {'template_versions': [{'version': '2013-05-23',
30 'type': 'hot'}]}
31
32 class FakeClient:
33 def get(self, *args, **kwargs):
34 assert ('GET', args[0]) == expect
35 return FakeResponse()
36
37 manager = template_versions.TemplateVersionManager(FakeClient())
38 versions = manager.list()
39 self.assertEqual('2013-05-23', getattr(versions[0], 'version'))
40 self.assertEqual('hot', getattr(versions[0], 'type'))
41
42 def test_get(self):
43 expect = ('GET', '/template_versions/heat_template_version.2015-04-30'
44 '/functions')
45
46 class FakeResponse:
47 def json(self):
48 return {'template_functions': [{'function': 'get_attr'}]}
49
50 class FakeClient:
51 def get(self, *args, **kwargs):
52 assert ('GET', args[0]) == expect
53 return FakeResponse()
54
55 manager = template_versions.TemplateVersionManager(FakeClient())
56 functions = manager.get('heat_template_version.2015-04-30')
57 self.assertEqual('get_attr', getattr(functions[0], 'function'))