Fixed unittests
Unittests where broken after ceilometerclient update because ceilometerclient now requires the auth_url as parameter. Closes Bug: #1491733 Change-Id: Id7381dfecf09c26b3be858ba664595b4c6f1cac7
This commit is contained in:
parent
4b08e58a8c
commit
39a8af7704
|
@ -631,6 +631,7 @@ class CeilometerAlarms(Resources):
|
|||
def get_token():
|
||||
return session.token
|
||||
self.client = ceilometer_client.Client(
|
||||
auth_url=session.auth_url,
|
||||
endpoint=session.get_endpoint("metering"),
|
||||
token=get_token, insecure=session.insecure)
|
||||
self.project_id = session.project_id
|
||||
|
|
|
@ -19,6 +19,7 @@ TOKEN_ID = '04c7d5ffaeef485f9dc69c06db285bdb'
|
|||
USER_ID = 'c4da488862bd435c9e6c0275a0d0e49a'
|
||||
PROJECT_ID = '225da22d3ce34b15877ea70b2a575f58'
|
||||
|
||||
AUTH_URL = "http://localhost:5000/v2.0"
|
||||
VOLUME_PUBLIC_ENDPOINT = 'http://public:8776/v1/225da22d3ce34b15877ea70b2a575f58'
|
||||
IMAGE_PUBLIC_ENDPOINT = 'http://public:9292'
|
||||
STORAGE_PUBLIC_ENDPOINT = 'http://public:8080/v1/AUTH_ee5b90900a4b4e85938b0ceadf4467f8'
|
||||
|
@ -34,6 +35,28 @@ COMPUTE_INTERNAL_ENDPOINT = 'http://nova.usr.lab0.aub.cw-labs.net:8774/v2/43c9e2
|
|||
METERING_INTERNAL_ENDPOINT = 'http://ceilometer.usr.lab0.aub.cw-labs.net:8777'
|
||||
ORCHESTRATION_INTERNAL_ENDPOINT = 'http://heat.usr.lab0.aub.cw-labs.net:8004/v1'
|
||||
|
||||
AUTH_URL_RESPONSE = {
|
||||
u'version': {
|
||||
u'id': u'v2.0',
|
||||
u'links': [
|
||||
{u'href': u'%s' % AUTH_URL, u'rel': u'self'},
|
||||
{u'href': u'http://docs.openstack.org/api/openstack-identity-service/2.0/content/',
|
||||
u'rel': u'describedby',
|
||||
u'type': u'text/html'},
|
||||
{u'href': u'http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf',
|
||||
u'rel': u'describedby',
|
||||
u'type': u'application/pdf'}
|
||||
],
|
||||
u'media-types': [
|
||||
{u'base': u'application/json',
|
||||
u'type': u'application/vnd.openstack.identity-v2.0+json'},
|
||||
{u'base': u'application/xml',
|
||||
u'type': u'application/vnd.openstack.identity-v2.0+xml'}
|
||||
],
|
||||
u'status': u'stable',
|
||||
u'updated': u'2014-04-17T00:00:00Z'
|
||||
}
|
||||
}
|
||||
|
||||
STORAGE_CONTAINERS = ['janeausten', 'marktwain']
|
||||
STORAGE_OBJECTS = [{'container': 'janeausten', 'name': 'foo'},
|
||||
|
|
|
@ -29,14 +29,19 @@ import json as jsonutils
|
|||
import httpretty
|
||||
import testtools
|
||||
|
||||
|
||||
from ospurge import ospurge
|
||||
from ospurge.tests import client_fixtures
|
||||
|
||||
# Disable InsecurePlatformWarning which is irrelevant in unittests with
|
||||
# mocked https requests and only clutters the results.
|
||||
import requests
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
|
||||
|
||||
USERNAME = "username"
|
||||
PASSWORD = "password"
|
||||
PROJECT_NAME = "project"
|
||||
AUTH_URL = "http://localhost:5000/v2.0"
|
||||
AUTH_URL = client_fixtures.AUTH_URL
|
||||
|
||||
|
||||
class HttpTest(testtools.TestCase):
|
||||
|
@ -101,6 +106,13 @@ class TestResourcesBase(HttpTest):
|
|||
self.stub_auth()
|
||||
self.session = ospurge.Session(USERNAME, PASSWORD,
|
||||
client_fixtures.PROJECT_ID, AUTH_URL)
|
||||
# We can't add other stubs in subclasses setUp because
|
||||
# httpretty.dactivate() is called after this set_up (so during the
|
||||
# super call to this method in subclasses). and extra stubs will not
|
||||
# work. if you need extra stubs to be done during setUp, write them
|
||||
# in an 'extra_set_up' method. instead of in the subclasses setUp
|
||||
if hasattr(self, 'extra_set_up'):
|
||||
self.extra_set_up()
|
||||
|
||||
@httpretty.activate
|
||||
def _test_list(self):
|
||||
|
@ -604,6 +616,11 @@ class TestGlanceImages(TestResourcesBase):
|
|||
class TestCeilometerAlarms(TestResourcesBase):
|
||||
TEST_URL = client_fixtures.METERING_PUBLIC_ENDPOINT
|
||||
|
||||
def extra_set_up(self):
|
||||
self.stub_url(
|
||||
'GET', base_url=AUTH_URL, json=client_fixtures.AUTH_URL_RESPONSE)
|
||||
self.resources = ospurge.CeilometerAlarms(self.session)
|
||||
|
||||
def stub_list(self):
|
||||
self.stub_url('GET', parts=['v2', 'alarms'],
|
||||
json=client_fixtures.ALARMS_LIST)
|
||||
|
@ -614,7 +631,6 @@ class TestCeilometerAlarms(TestResourcesBase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestCeilometerAlarms, self).setUp()
|
||||
self.resources = ospurge.CeilometerAlarms(self.session)
|
||||
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
|
|
Loading…
Reference in New Issue