From b1787bd43e6c7a56523d0bc246008815fb508454 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 22 Nov 2012 08:13:33 +1300 Subject: [PATCH] Use a real context for tests. No more DummyContext. Change-Id: Ifbb7cea17b9fa0df90c15867712a74f4d8a5115d --- heat/tests/test_autoscaling.py | 13 +++++++------ heat/tests/test_dbinstance.py | 15 ++++++++------- heat/tests/test_eip.py | 13 +++++++------ heat/tests/test_quantum.py | 13 +++++++------ heat/tests/test_s3.py | 13 +++++++------ heat/tests/test_user.py | 13 +++++++------ heat/tests/test_volume.py | 13 +++++++------ 7 files changed, 50 insertions(+), 43 deletions(-) diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index f87170b1ff..e581d07ddb 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -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 diff --git a/heat/tests/test_dbinstance.py b/heat/tests/test_dbinstance.py index ba419a422d..12c7efbe18 100644 --- a/heat/tests/test_dbinstance.py +++ b/heat/tests/test_dbinstance.py @@ -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 diff --git a/heat/tests/test_eip.py b/heat/tests/test_eip.py index 14c7378ea3..6dba9f1ff2 100644 --- a/heat/tests/test_eip.py +++ b/heat/tests/test_eip.py @@ -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 diff --git a/heat/tests/test_quantum.py b/heat/tests/test_quantum.py index a610fadaa5..a5ab0e9d0b 100644 --- a/heat/tests/test_quantum.py +++ b/heat/tests/test_quantum.py @@ -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 diff --git a/heat/tests/test_s3.py b/heat/tests/test_s3.py index f1cf2fd365..c9b4fad413 100644 --- a/heat/tests/test_s3.py +++ b/heat/tests/test_s3.py @@ -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 diff --git a/heat/tests/test_user.py b/heat/tests/test_user.py index 990139a2c9..04244283ff 100644 --- a/heat/tests/test_user.py +++ b/heat/tests/test_user.py @@ -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 diff --git a/heat/tests/test_volume.py b/heat/tests/test_volume.py index ae9eb16769..20320f2319 100644 --- a/heat/tests/test_volume.py +++ b/heat/tests/test_volume.py @@ -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