From 663ed27a2d7b3cb3a5290e0516eb8d602d7e65ba Mon Sep 17 00:00:00 2001 From: Cerberus Date: Tue, 28 Sep 2010 12:56:01 -0500 Subject: Testing testing testing --- nova/tests/api/rackspace/servers.py | 37 +++++++++++++++++++++++++++------ nova/tests/api/rackspace/test_helper.py | 22 ++++++++++++++++++-- 2 files changed, 51 insertions(+), 8 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/rackspace/servers.py b/nova/tests/api/rackspace/servers.py index 674dab0b6..a22736dd2 100644 --- a/nova/tests/api/rackspace/servers.py +++ b/nova/tests/api/rackspace/servers.py @@ -80,9 +80,19 @@ class ServersTest(unittest.TestCase): self.assertEqual(s.get('imageId', None), None) i += 1 - def test_create_instance(self): - pass - + #def test_create_instance(self): + # test_helper.stub_out_image_translator(self.stubs) + # body = dict(server=dict( + # name='server_test', imageId=2, flavorId=2, metadata={}, + # personality = {} + # )) + # req = webob.Request.blank('/v1.0/servers') + # req.method = 'POST' + # req.body = json.dumps(body) + + # res = req.get_response(nova.api.API()) + + # print res def test_update_server_password(self): pass @@ -119,22 +129,37 @@ class ServersTest(unittest.TestCase): i += 1 def test_server_reboot(self): + body = dict(server=dict( + name='server_test', imageId=2, flavorId=2, metadata={}, + personality = {} + )) req = webob.Request.blank('/v1.0/servers/1/action') req.method = 'POST' + req.content_type= 'application/json' + req.body = json.dumps(body) res = req.get_response(nova.api.API()) - res_dict = json.loads(res.body) def test_server_rebuild(self): + body = dict(server=dict( + name='server_test', imageId=2, flavorId=2, metadata={}, + personality = {} + )) req = webob.Request.blank('/v1.0/servers/1/action') req.method = 'POST' + req.content_type= 'application/json' + req.body = json.dumps(body) res = req.get_response(nova.api.API()) - res_dict = json.loads(res.body) def test_server_resize(self): + body = dict(server=dict( + name='server_test', imageId=2, flavorId=2, metadata={}, + personality = {} + )) req = webob.Request.blank('/v1.0/servers/1/action') req.method = 'POST' + req.content_type= 'application/json' + req.body = json.dumps(body) res = req.get_response(nova.api.API()) - res_dict = json.loads(res.body) def test_delete_server_instance(self): req = webob.Request.blank('/v1.0/servers/1') diff --git a/nova/tests/api/rackspace/test_helper.py b/nova/tests/api/rackspace/test_helper.py index d44b8c30e..09ff26ac7 100644 --- a/nova/tests/api/rackspace/test_helper.py +++ b/nova/tests/api/rackspace/test_helper.py @@ -1,10 +1,12 @@ -from nova import utils +import json import webob import webob.dec import datetime +import nova.api.rackspace.auth +import nova.api.rackspace._id_translator from nova.wsgi import Router from nova import auth -import nova.api.rackspace.auth +from nova import utils from nova import flags FLAGS = flags.FLAGS @@ -32,8 +34,24 @@ def fake_auth_init(self): @webob.dec.wsgify def fake_wsgi(self, req): req.environ['nova.context'] = dict(user=dict(id=1)) + if req.body: + req.environ['inst_dict'] = json.loads(req.body) return self.application +def stub_out_image_translator(stubs): + class FakeTranslator(object): + def __init__(self, id_type, service_name): + pass + + def to_rs_id(self, id): + return id + + def from_rs_id(self, id): + return id + + stubs.Set(nova.api.rackspace._id_translator, + 'RackspaceAPIIdTranslator', FakeTranslator) + def stub_out_auth(stubs): def fake_auth_init(self, app): self.application = app -- cgit