Use a real context for tests.

No more DummyContext.

Change-Id: Ifbb7cea17b9fa0df90c15867712a74f4d8a5115d
This commit is contained in:
Steve Baker 2012-11-22 08:13:33 +13:00
parent 66ef27527d
commit b1787bd43e
7 changed files with 50 additions and 43 deletions

View 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

View 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

View 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

View 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

View 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

View 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

View 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