]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Use a real context for tests.
authorSteve Baker <sbaker@redhat.com>
Wed, 21 Nov 2012 19:13:33 +0000 (08:13 +1300)
committerSteve Baker <sbaker@redhat.com>
Wed, 21 Nov 2012 19:13:33 +0000 (08:13 +1300)
No more DummyContext.

Change-Id: Ifbb7cea17b9fa0df90c15867712a74f4d8a5115d

heat/tests/test_autoscaling.py
heat/tests/test_dbinstance.py
heat/tests/test_eip.py
heat/tests/test_quantum.py
heat/tests/test_s3.py
heat/tests/test_user.py
heat/tests/test_volume.py

index f87170b1ff5a6ec14c2380a8d8d1bf6e715d443a..e581d07ddba8d71f9bdd02736c50e2f09d722782 100644 (file)
@@ -23,6 +23,7 @@ import json
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.engine.resources import autoscaling as asc
 from heat.engine.resources import loadbalancer
 from heat.engine import parser
@@ -48,14 +49,14 @@ class AutoScalingTest(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant = 'test_tenant'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
+        ctx = context.RequestContext.from_dict({
+            'tenant': 'test_tenant',
+            'username': 'test_username',
+            'password': 'password',
+            'auth_url': 'http://localhost:5000/v2.0'})
         template = parser.Template(t)
         params = parser.Parameters('test_stack', template, {'KeyName': 'test'})
-        stack = parser.Stack(DummyContext(), 'test_stack', template,
+        stack = parser.Stack(ctx, 'test_stack', template,
                              params, stack_id=-1)
 
         return stack
index ba419a422dbe905895adcb2d17dc0551617a5252..12c7efbe18dc91aa120198213767bba6145aad15 100644 (file)
@@ -23,6 +23,7 @@ import json
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.common import exception
 from heat.engine import parser
 from heat.engine.resources import stack
@@ -50,15 +51,15 @@ class DBInstanceTest(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant = 'test_tenant'
-            tenant_id = '1234abcd'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
+        ctx = context.RequestContext.from_dict({
+            'tenant': 'test_tenant',
+            'tenant_id': '1234abcd',
+            'username': 'test_username',
+            'password': 'password',
+            'auth_url': 'http://localhost:5000/v2.0'})
         template = parser.Template(t)
         params = parser.Parameters('test_stack', template, {'KeyName': 'test'})
-        stack = parser.Stack(DummyContext(), 'test_stack', template,
+        stack = parser.Stack(ctx, 'test_stack', template,
                              params, stack_id=-1)
 
         return stack
index 14c7378ea3f8b856b6b322371db5b5ec2020c277..6dba9f1ff28aedd61838c53f93aff059e9edc8d7 100644 (file)
@@ -23,6 +23,7 @@ import json
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.engine.resources import eip
 from heat.engine import parser
 from heat.tests.v1_1 import fakes
@@ -51,14 +52,14 @@ class EIPTest(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant = 'test_tenant'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
+        ctx = context.RequestContext.from_dict({
+            'tenant': 'test_tenant',
+            'username': 'test_username',
+            'password': 'password',
+            'auth_url': 'http://localhost:5000/v2.0'})
         template = parser.Template(t)
         params = parser.Parameters('test_stack', template, {'KeyName': 'test'})
-        stack = parser.Stack(DummyContext(), 'test_stack', template,
+        stack = parser.Stack(ctx, 'test_stack', template,
                              params, stack_id=-1)
 
         return stack
index a610fadaa56e63951c0087581ae49f7b2283aeca..a5ab0e9d0b24074dbf6b85ab91317356e760cb2f 100644 (file)
@@ -23,6 +23,7 @@ import json
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.common import exception
 from heat.engine.resources import properties
 from heat.engine.resources.quantum import net
@@ -85,12 +86,12 @@ class QuantumTest(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant = 'test_tenant'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
-        stack = parser.Stack(DummyContext(), 'test_stack', parser.Template(t),
+        ctx = context.RequestContext.from_dict({
+            'tenant': 'test_tenant',
+            'username': 'test_username',
+            'password': 'password',
+            'auth_url': 'http://localhost:5000/v2.0'})
+        stack = parser.Stack(ctx, 'test_stack', parser.Template(t),
             stack_id=-1, parameters={'external_network': 'abcd1234'})
 
         return stack
index f1cf2fd3659162b6b3a27131a3d43c0893e2ea33..c9b4fad413484dcb4aa0c24a8a6d1830676917b3 100644 (file)
@@ -24,6 +24,7 @@ import json
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.engine.resources import s3
 from heat.engine import parser
 from utils import skip_if
@@ -62,12 +63,12 @@ class s3Test(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant = 'test_tenant'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
-        stack = parser.Stack(DummyContext(), 'test_stack', parser.Template(t),
+        ctx = context.RequestContext.from_dict({
+            'tenant': 'test_tenant',
+            'username': 'test_username',
+            'password': 'password',
+            'auth_url': 'http://localhost:5000/v2.0'})
+        stack = parser.Stack(ctx, 'test_stack', parser.Template(t),
                              stack_id=-1)
 
         return stack
index 990139a2c9e4db5a1213de70ff2d38312b434162..04244283ff0326ca3eee10404a03b23092909792 100644 (file)
@@ -24,6 +24,7 @@ import unittest
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.common import exception
 from heat.common import config
 from heat.engine import parser
@@ -72,11 +73,11 @@ class UserTest(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant_id = 'test_tenant'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
+        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)
         params = parser.Parameters('test_stack',
                                    template,
@@ -84,7 +85,7 @@ class UserTest(unittest.TestCase):
                                     'DBRootPassword': 'test',
                                     'DBUsername': 'test',
                                     'DBPassword': 'test'})
-        stack = parser.Stack(DummyContext(), 'test_stack', template,
+        stack = parser.Stack(ctx, 'test_stack', template,
                              params, stack_id=-1)
 
         return stack
index ae9eb1676954afe4a2f6ccf58b63e8ad6f719126..20320f231961b1e4988284c5c22cf12d13de8010 100644 (file)
@@ -24,6 +24,7 @@ import unittest
 
 from nose.plugins.attrib import attr
 
+from heat.common import context
 from heat.engine import parser
 from heat.engine.resources import volume as vol
 from heat.tests.v1_1 import fakes
@@ -57,14 +58,14 @@ class VolumeTest(unittest.TestCase):
         return t
 
     def parse_stack(self, t):
-        class DummyContext():
-            tenant = 'test_tenant'
-            username = 'test_username'
-            password = 'password'
-            auth_url = 'http://localhost:5000/v2.0'
+        ctx = context.RequestContext.from_dict({
+            'tenant': 'test_tenant',
+            'username': 'test_username',
+            'password': 'password',
+            'auth_url': 'http://localhost:5000/v2.0'})
         template = parser.Template(t)
         params = parser.Parameters('test_stack', template, {'KeyName': 'test'})
-        stack = parser.Stack(DummyContext(), 'test_stack', template,
+        stack = parser.Stack(ctx, 'test_stack', template,
                              params, stack_id=-1)
 
         return stack