]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat tests : add parse_stack function to test utils
authorSteven Hardy <shardy@redhat.com>
Fri, 3 May 2013 12:31:35 +0000 (13:31 +0100)
committerSteven Hardy <shardy@redhat.com>
Fri, 3 May 2013 16:37:33 +0000 (17:37 +0100)
Add convenience function parse_stack to utils so it can be
reused in test to avoid duplication

Change-Id: I608e2227c695a9faecbd8ff78a1339b47174a006

heat/tests/utils.py

index fed91f67d0f0a51821f77ef3f1ca250560aebfa3..a6d1ef5a1ac65a60de721edd69f482ab2315259d 100644 (file)
@@ -15,6 +15,9 @@
 
 from testtools import skipIf
 
+from heat.common import context
+from heat.engine import parser
+
 from heat.db.sqlalchemy.session import get_engine
 from heat.db import migration
 
@@ -55,3 +58,16 @@ def setup_dummy_db():
     migration.db_sync()
     engine = get_engine()
     conn = engine.connect()
+
+
+def parse_stack(t, params={}, stack_name='test_stack'):
+    ctx = context.RequestContext.from_dict({'tenant_id': 'test_tenant',
+                                            'username': 'test_username',
+                                            'password': 'password',
+                                            'auth_url':
+                                            'http://localhost:5000/v2.0'})
+    template = parser.Template(t)
+    parameters = parser.Parameters(stack_name, template, params)
+    stack = parser.Stack(ctx, stack_name, template, parameters)
+
+    return stack