Test Nova API calls
This commit is contained in:
parent
90c7119bb6
commit
5af58cc6a1
@ -29,5 +29,5 @@ class Node(object):
|
||||
"imageId": image,
|
||||
"flavourId": node_type,
|
||||
}}
|
||||
resp, body = self.api.post(url, body)
|
||||
resp, body = self.nova.post(url, body)
|
||||
return body
|
||||
|
@ -1,15 +1,41 @@
|
||||
import unittest
|
||||
import logging
|
||||
|
||||
import mock
|
||||
import httplib2
|
||||
|
||||
import mock_objects
|
||||
from libra.mgm.nova import Node
|
||||
|
||||
fake_response = httplib2.Response({"status": 200})
|
||||
fake_body = '{"hi": "there"}'
|
||||
mock_request = mock.Mock(return_value=(fake_response, fake_body))
|
||||
|
||||
|
||||
class TestLBaaSMgmTask(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.logger = logging.getLogger('lbass_mgm_test')
|
||||
self.lh = mock.MockLoggingHandler()
|
||||
self.lh = mock_objects.MockLoggingHandler()
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
self.logger.addHandler(self.lh)
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestLBaaSMgmNova(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.api = Node(
|
||||
"username", "password", "auth_test", "tenant1", "region1"
|
||||
)
|
||||
self.api.nova.management_url = "http://example.com"
|
||||
self.api.nova.auth_token = "token"
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testCreateNode(self):
|
||||
@mock.patch.object(httplib2.Http, "request", mock_request)
|
||||
@mock.patch('time.time', mock.Mock(return_value=1234))
|
||||
def testCreateCall():
|
||||
data = self.api.create('4321', '123', '321')
|
||||
self.assertEqual(data, {"hi": "there"})
|
||||
|
@ -1,3 +1,4 @@
|
||||
gearman
|
||||
python-daemon
|
||||
requests
|
||||
python_novaclient
|
||||
|
@ -1 +1,3 @@
|
||||
pytest-pep8
|
||||
mock
|
||||
httplib2
|
||||
|
Loading…
x
Reference in New Issue
Block a user