summaryrefslogtreecommitdiff
path: root/heat/tests/test_environment.py
diff options
context:
space:
mode:
authorAngus Salkeld <asalkeld@redhat.com>2013-06-13 13:59:08 +1000
committerAngus Salkeld <asalkeld@redhat.com>2013-06-17 20:23:38 +1000
commitb0585a6dadbeb8de76a8440d4b4d70eb17fd05d4 (patch)
tree005b2a83fb1abe578f8bb32cb334f43541f496c1 /heat/tests/test_environment.py
parentd0cdccace0240ce116a3900fe45cb60c5374e38a (diff)
downloadheat-b0585a6dadbeb8de76a8440d4b4d70eb17fd05d4.tar.gz
Initial Environment class and test
This implements the "resource-registry" and "parameters" section I am holding off on the "properties" section until we really know we need it. blueprint environments Change-Id: Ib6e9e5cd1c68c255dc048bdde21a6b3e1dc54243
Diffstat (limited to 'heat/tests/test_environment.py')
-rw-r--r--heat/tests/test_environment.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/heat/tests/test_environment.py b/heat/tests/test_environment.py
new file mode 100644
index 000000000..a3363954f
--- /dev/null
+++ b/heat/tests/test_environment.py
@@ -0,0 +1,64 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from heat.engine import environment
+
+
+class EnvironmentTest(testtools.TestCase):
+ def test_load_old_parameters(self):
+ old = {u'a': u'ff', u'b': u'ss'}
+ expected = {u'parameters': old,
+ u'resource_registry': {u'resources': {}}}
+ env = environment.Environment(old)
+ self.assertEqual(expected, env.user_env_as_dict())
+
+ def test_load_new_env(self):
+ new_env = {u'parameters': {u'a': u'ff', u'b': u'ss'},
+ u'resource_registry': {u'OS::Food': 'fruity'}}
+ env = environment.Environment(new_env)
+ self.assertEqual(new_env, env.user_env_as_dict())
+
+ def test_global_registry(self):
+ new_env = {u'parameters': {u'a': u'ff', u'b': u'ss'},
+ u'resource_registry': {u'OS::*': 'CloudX::*'}}
+ env = environment.Environment(new_env)
+ self.assertEqual('CloudX::Compute::Server',
+ env.get_resource_type('OS::Compute::Server',
+ 'my_db_server'))
+
+ def test_map_one_resource_type(self):
+ new_env = {u'parameters': {u'a': u'ff', u'b': u'ss'},
+ u'resource_registry': {u'resources':
+ {u'my_db_server':
+ {u'OS::DBInstance': 'db.yaml'}}}}
+ env = environment.Environment(new_env)
+ self.assertEqual('db.yaml',
+ env.get_resource_type('OS::DBInstance',
+ 'my_db_server'))
+ self.assertEqual('OS::Compute::Server',
+ env.get_resource_type('OS::Compute::Server',
+ 'my_other_server'))
+
+ def test_map_all_resources_of_type(self):
+ new_env = {u'parameters': {u'a': u'ff', u'b': u'ss'},
+ u'resource_registry':
+ {u'OS::Networking::FloatingIP': 'OS::Nova::FloatingIP',
+ u'OS::Loadbalancer': 'lb.yaml'}}
+ env = environment.Environment(new_env)
+ self.assertEqual('OS::Nova::FloatingIP',
+ env.get_resource_type('OS::Networking::FloatingIP',
+ 'my_fip'))