summaryrefslogtreecommitdiff
path: root/heat/tests/test_dbinstance.py
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2013-05-03 11:43:54 +0100
committerSteven Hardy <shardy@redhat.com>2013-05-03 17:37:33 +0100
commit6e9a0e468317bd5fc50517a58448408ef5fa24ce (patch)
tree01cee6b743c084ac9bedc11d0178e3ea25e6bd25 /heat/tests/test_dbinstance.py
parenta6cd037bd893933249f10d0952a2881ac7e0ee40 (diff)
downloadheat-6e9a0e468317bd5fc50517a58448408ef5fa24ce.tar.gz
heat tests : convert most tests to inline templates
Convert to inline minimal templates, to remove dependency on in-tree templates which we plan to remove. Note there are still some more tests remaining which need similar changes (shardy todo) Change-Id: I0864d1f15ea3b815d449277387440157f104bbf3
Diffstat (limited to 'heat/tests/test_dbinstance.py')
-rw-r--r--heat/tests/test_dbinstance.py77
1 files changed, 40 insertions, 37 deletions
diff --git a/heat/tests/test_dbinstance.py b/heat/tests/test_dbinstance.py
index 3b5141bbf..0a5728d98 100644
--- a/heat/tests/test_dbinstance.py
+++ b/heat/tests/test_dbinstance.py
@@ -13,18 +13,44 @@
# under the License.
-import os
-
import mox
-from heat.common import context
from heat.common import exception
from heat.common import template_format
-from heat.engine import parser
from heat.engine import scheduler
from heat.engine.resources import dbinstance as dbi
from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
+from heat.tests.utils import parse_stack
+
+
+rds_template = '''
+{
+ "AWSTemplateFormatVersion" : "2010-09-09",
+ "Description" : "RDS Test",
+ "Parameters" : {
+ "KeyName" : {
+ "Description" : "KeyName",
+ "Type" : "String",
+ "Default" : "test"
+ }
+ },
+ "Resources" : {
+ "DatabaseServer": {
+ "Type": "AWS::RDS::DBInstance",
+ "Properties": {
+ "DBName" : "wordpress",
+ "Engine" : "MySQL",
+ "MasterUsername" : "admin",
+ "DBInstanceClass" : "db.m1.small",
+ "DBSecurityGroups" : [],
+ "AllocatedStorage" : "5",
+ "MasterUserPassword": "admin"
+ }
+ }
+ }
+}
+'''
class DBInstanceTest(HeatTestCase):
@@ -34,27 +60,6 @@ class DBInstanceTest(HeatTestCase):
self.m.StubOutWithMock(dbi.DBInstance, 'create_with_template')
self.m.StubOutWithMock(dbi.DBInstance, 'nested')
- def load_template(self):
- self.path = os.path.dirname(os.path.realpath(__file__)).\
- replace('heat/tests', 'templates')
- f = open("%s/WordPress_With_RDS.template" % self.path)
- t = template_format.parse(f.read())
- f.close()
- return t
-
- def parse_stack(self, t):
- 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(ctx, 'test_stack', template, params)
-
- return stack
-
def create_dbinstance(self, t, stack, resource_name):
resource = dbi.DBInstance(resource_name,
t['Resources'][resource_name],
@@ -73,16 +78,14 @@ class DBInstanceTest(HeatTestCase):
class FakeNested:
resources = {'DatabaseInstance': FakeDatabaseInstance()}
- params = {
- 'AllocatedStorage': u'5',
- 'DBInstanceClass': u'db.m1.small',
- 'DBName': u'wordpress',
- 'DBSecurityGroups': '',
- 'KeyName': 'test',
- 'MasterUserPassword': u'admin',
- 'MasterUsername': u'admin',
- 'Port': '3306'
- }
+ params = {'DBSecurityGroups': '',
+ 'MasterUsername': u'admin',
+ 'MasterUserPassword': u'admin',
+ 'DBName': u'wordpress',
+ 'KeyName': u'test',
+ 'AllocatedStorage': u'5',
+ 'DBInstanceClass': u'db.m1.small',
+ 'Port': '3306'}
dbi.DBInstance.create_with_template(mox.IgnoreArg(),
params).AndReturn(None)
@@ -93,8 +96,8 @@ class DBInstanceTest(HeatTestCase):
dbi.DBInstance.nested().MultipleTimes().AndReturn(fn)
self.m.ReplayAll()
- t = self.load_template()
- s = self.parse_stack(t)
+ t = template_format.parse(rds_template)
+ s = parse_stack(t)
resource = self.create_dbinstance(t, s, 'DatabaseServer')
self.assertEqual('0.0.0.0', resource.FnGetAtt('Endpoint.Address'))