summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/rackspace/auth.py4
-rw-r--r--nova/tests/api/rackspace/flavors.py15
-rw-r--r--nova/tests/api/rackspace/servers.py42
-rw-r--r--nova/tests/api/rackspace/test_helper.py29
4 files changed, 70 insertions, 20 deletions
diff --git a/nova/tests/api/rackspace/auth.py b/nova/tests/api/rackspace/auth.py
index 429c22ad2..a6e10970f 100644
--- a/nova/tests/api/rackspace/auth.py
+++ b/nova/tests/api/rackspace/auth.py
@@ -15,8 +15,8 @@ class Test(unittest.TestCase):
'__init__', test_helper.fake_auth_init)
test_helper.FakeAuthManager.auth_data = {}
test_helper.FakeAuthDatabase.data = {}
- self.stubs.Set(nova.api.rackspace, 'RateLimitingMiddleware',
- test_helper.FakeRateLimiter)
+ test_helper.stub_out_rate_limiting(self.stubs)
+ test_helper.stub_for_testing(self.stubs)
def tearDown(self):
self.stubs.UnsetAll()
diff --git a/nova/tests/api/rackspace/flavors.py b/nova/tests/api/rackspace/flavors.py
index fb8ba94a5..7bd1ea1c4 100644
--- a/nova/tests/api/rackspace/flavors.py
+++ b/nova/tests/api/rackspace/flavors.py
@@ -16,19 +16,32 @@
# under the License.
import unittest
+import stubout
+import nova.api
from nova.api.rackspace import flavors
+from nova.tests.api.rackspace import test_helper
from nova.tests.api.test_helper import *
class FlavorsTest(unittest.TestCase):
def setUp(self):
self.stubs = stubout.StubOutForTesting()
+ test_helper.FakeAuthManager.auth_data = {}
+ test_helper.FakeAuthDatabase.data = {}
+ test_helper.stub_for_testing(self.stubs)
+ test_helper.stub_out_rate_limiting(self.stubs)
+ test_helper.stub_out_auth(self.stubs)
def tearDown(self):
self.stubs.UnsetAll()
def test_get_flavor_list(self):
- pass
+ req = webob.Request.blank('/v1.0/flavors')
+ res = req.get_response(nova.api.API())
+ print res
def test_get_flavor_by_id(self):
pass
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/nova/tests/api/rackspace/servers.py b/nova/tests/api/rackspace/servers.py
index 2cfb8d45f..0f3483207 100644
--- a/nova/tests/api/rackspace/servers.py
+++ b/nova/tests/api/rackspace/servers.py
@@ -17,36 +17,60 @@
import unittest
import stubout
-from nova.api.rackspace import servers
import nova.api.rackspace
+import nova.db.api
+from nova import flags
+from nova.api.rackspace import servers
+from nova.db.sqlalchemy.models import Instance
from nova.tests.api.test_helper import *
from nova.tests.api.rackspace import test_helper
+from nova import db
+
+FLAGS = flags.FLAGS
+
+def return_server(context, id):
+ return stub_instance(id)
+
+def return_servers(context):
+ return [stub_instance(i) for i in xrange(5)]
+
+def stub_instance(id):
+ return Instance(id=id, state=0, )
class ServersTest(unittest.TestCase):
def setUp(self):
self.stubs = stubout.StubOutForTesting()
test_helper.FakeAuthManager.auth_data = {}
test_helper.FakeAuthDatabase.data = {}
+ test_helper.stub_for_testing(self.stubs)
+ test_helper.stub_out_rate_limiting(self.stubs)
test_helper.stub_out_auth(self.stubs)
+ self.stubs.Set(nova.db.api, 'instance_get_all', return_servers)
+ self.stubs.Set(nova.db.api, 'instance_get', return_server)
def tearDown(self):
self.stubs.UnsetAll()
- def test_get_server_list(self):
- req = webob.Request.blank('/v1.0/servers')
- req.get_response(nova.api.API())
+ def test_get_server_by_id(self):
+ req = webob.Request.blank('/v1.0/servers/1')
+ res = req.get_response(nova.api.API())
+ print res
- def test_create_instance(self):
+ def test_get_backup_schedule(self):
pass
- def test_get_server_by_id(self):
- pass
+ def test_get_server_list(self):
+ req = webob.Request.blank('/v1.0/servers')
+ res = req.get_response(nova.api.API())
+ print res
- def test_get_backup_schedule(self):
+ def test_create_instance(self):
pass
def test_get_server_details(self):
- pass
+ req = webob.Request.blank('/v1.0/servers/detail')
+ res = req.get_response(nova.api.API())
+ print res
def test_get_server_ips(self):
pass
diff --git a/nova/tests/api/rackspace/test_helper.py b/nova/tests/api/rackspace/test_helper.py
index 1fb2a19cc..971eaf20a 100644
--- a/nova/tests/api/rackspace/test_helper.py
+++ b/nova/tests/api/rackspace/test_helper.py
@@ -1,9 +1,13 @@
+from nova import utils
import webob
import webob.dec
import datetime
from nova.wsgi import Router
from nova import auth
import nova.api.rackspace.auth
+from nova import flags
+
+FLAGS = flags.FLAGS
class Context(object):
pass
@@ -25,27 +29,36 @@ def fake_auth_init(self):
self.auth = FakeAuthManager()
self.host = 'foo'
+@webob.dec.wsgify
+def fake_wsgi(self, req):
+ return self.application
+
def stub_out_auth(stubs):
def fake_auth_init(self, app):
self.application = app
+
+ stubs.Set(nova.api.rackspace.AuthMiddleware,
+ '__init__', fake_auth_init)
+ stubs.Set(nova.api.rackspace.AuthMiddleware,
+ '__call__', fake_wsgi)
+def stub_out_rate_limiting(stubs):
def fake_rate_init(self, app):
super(nova.api.rackspace.RateLimitingMiddleware, self).__init__(app)
self.application = app
- @webob.dec.wsgify
- def fake_wsgi(self, req):
- return self.application
-
- stubs.Set(nova.api.rackspace.AuthMiddleware,
- '__init__', fake_auth_init)
stubs.Set(nova.api.rackspace.RateLimitingMiddleware,
'__init__', fake_rate_init)
- stubs.Set(nova.api.rackspace.AuthMiddleware,
- '__call__', fake_wsgi)
+
stubs.Set(nova.api.rackspace.RateLimitingMiddleware,
'__call__', fake_wsgi)
+def stub_for_testing(stubs):
+ def get_my_ip():
+ return '127.0.0.1'
+ stubs.Set(nova.utils, 'get_my_ip', get_my_ip)
+ FLAGS.FAKE_subdomain = 'rs'
+
class FakeAuthDatabase(object):
data = {}