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
5 # http://www.apache.org/licenses/LICENSE-2.0
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
13 from toscaparser.nodetemplate import NodeTemplate
14 from toscaparser.tests.base import TestCase
15 from toscaparser.utils.gettextutils import _
16 import toscaparser.utils.yamlparser
17 from translator.hot.tosca.tosca_object_storage import ToscaObjectStorage
20 class ToscaObjectStoreTest(TestCase):
22 def _tosca_objectstore_test(self, tpl_snippet, expectedprops):
23 nodetemplates = (toscaparser.utils.yamlparser.
24 simple_parse(tpl_snippet)['node_templates'])
25 name = list(nodetemplates.keys())[0]
27 nodetemplate = NodeTemplate(name, nodetemplates)
28 tosca_object_store = ToscaObjectStorage(nodetemplate)
29 tosca_object_store.handle_properties()
30 if not self._compare_properties(tosca_object_store.properties,
32 raise Exception(_("Hot Properties are not"
33 " same as expected properties"))
35 # for time being rethrowing. Will be handled future based
39 def _compare_properties(self, hotprops, expectedprops):
40 return all(item in hotprops.items() for item in expectedprops.items())
42 def test_node_objectstorage_with_properties(self):
46 type: tosca.nodes.ObjectStorage
52 expectedprops = {'name': 'test',
53 'X-Container-Meta': {'Quota-Bytes': 1000000}}
54 self._tosca_objectstore_test(
58 def test_node_objectstorage_with_few_properties(self):
62 type: tosca.nodes.ObjectStorage
67 expectedprops = {'name': 'test',
68 'X-Container-Meta': {'Quota-Bytes': 1024}}
69 self._tosca_objectstore_test(