]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat tests : split user test into User/AccessKey
authorSteven Hardy <shardy@redhat.com>
Thu, 7 Feb 2013 15:33:17 +0000 (15:33 +0000)
committerSteven Hardy <shardy@redhat.com>
Fri, 8 Feb 2013 14:10:44 +0000 (14:10 +0000)
The test is testing two classes, User and AccessKey,
so make the tests separate

Change-Id: I79e183381ce69e2d2d564c254b2f903b60672e33
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/tests/test_user.py

index 2143e9adedd9b9fb93df0af9bab2e77d1dbc89b6..d65e4320ad963f347a833fa2e80f7e10282f9390 100644 (file)
@@ -29,7 +29,7 @@ from heat.tests import fakes
 from heat.openstack.common import cfg
 
 
-@attr(tag=['unit', 'resource', 'Unit'])
+@attr(tag=['unit', 'resource', 'User'])
 @attr(speed='fast')
 class UserTest(unittest.TestCase):
     def setUp(self):
@@ -111,6 +111,44 @@ class UserTest(unittest.TestCase):
         self.assertEqual('DELETE_COMPLETE', resource.state)
         self.m.VerifyAll()
 
+
+@attr(tag=['unit', 'resource', 'AccessKey'])
+@attr(speed='fast')
+class AccessKeyTest(unittest.TestCase):
+    def setUp(self):
+        self.m = mox.Mox()
+        self.fc = fakes.FakeKeystoneClient(username='test_stack.CfnUser')
+        cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role')
+
+    def tearDown(self):
+        self.m.UnsetStubs()
+        print "AccessKey teardown complete"
+
+    def load_template(self):
+        self.path = os.path.dirname(os.path.realpath(__file__)).\
+            replace('heat/tests', 'templates')
+        f = open("%s/Rails_Single_Instance.template" % self.path)
+        t = template_format.parse(f.read())
+        f.close()
+        return t
+
+    def parse_stack(self, t):
+        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,
+                                   {'KeyName': 'test',
+                                    'DBRootPassword': 'test',
+                                    'DBUsername': 'test',
+                                    'DBPassword': 'test'})
+        stack = parser.Stack(ctx, 'test_stack', template, params)
+
+        return stack
+
     def create_access_key(self, t, stack, resource_name):
         resource = user.AccessKey(resource_name,
                                   t['Resources'][resource_name],