From: Chris Alfonso Date: Wed, 18 Apr 2012 13:03:17 +0000 (-0400) Subject: Adding unit test for instance creation X-Git-Tag: 2014.1~1938^2~2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bad1eb37a5b3659e888a5840ed931aa11fc0e37b;p=openstack-build%2Fheat-build.git Adding unit test for instance creation --- diff --git a/heat/tests/test_resources.py b/heat/tests/test_resources.py index b67b444f..3c3d6135 100644 --- a/heat/tests/test_resources.py +++ b/heat/tests/test_resources.py @@ -25,6 +25,7 @@ class ResourcesTest(unittest.TestCase): def tearDown(self): self.m.UnsetStubs() + print "ResourcesTest teardown complete" def test_initialize_instance_from_template(self): f = open('../../templates/WordPress_Single_Instance_gold.template') @@ -52,7 +53,6 @@ class ResourcesTest(unittest.TestCase): self.m.ReplayAll() - t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2' t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server' instance = resources.Instance('test_resource_name',\ @@ -70,6 +70,27 @@ class ResourcesTest(unittest.TestCase): instance.itype_oflavor['256 MB Server'] = '256 MB Server' instance.create() + def test_initialize_instance_from_template(self): + f = open('templates/WordPress_Single_Instance_gold.template') + t = f.read() + f.close() + + stack = self._mox.CreateMockAnything() + stack.id().AndReturn(1) + + self._mox.StubOutWithMock(stack, 'resolve_static_refs') + stack.resolve_static_refs(t).AndReturn(t) + + self._mox.StubOutWithMock(stack, 'resolve_find_in_map') + stack.resolve_find_in_map(t).AndReturn(t) + + self._mox.StubOutWithMock(db_api, 'resource_get_by_name_and_stack') + db_api.resource_get_by_name_and_stack(None, 'test_resource_name', stack).AndReturn(None) + + self._mox.ReplayAll() + instance = resources.Instance('test_resource_name', t, stack) + + # allows testing of the test directly, shown below if __name__ == '__main__': sys.argv.append(__file__) diff --git a/run_tests.py b/run_tests.py index 65fc5008..73b18525 100644 --- a/run_tests.py +++ b/run_tests.py @@ -42,7 +42,6 @@ import os import unittest import sys -sys.path.append(os.environ['PYTHON_NOVACLIENT_SRC']) gettext.install('heat', unicode=1) from nose import config