Skip to content

Commit

Permalink
Code review changes for Bugfix for lp904407, /extensions tests
Browse files Browse the repository at this point in the history
Change-Id: I882f8170c69e5fb3690288a4a763ec2090e5167a
  • Loading branch information
donald-ngo committed Dec 15, 2011
1 parent 876adb2 commit 20b6bca
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tempest/openstack.py
Expand Up @@ -2,6 +2,7 @@
from tempest.services.nova.json.flavors_client import FlavorsClient
from tempest.services.nova.json.servers_client import ServersClient
from tempest.services.nova.json.limits_client import LimitsClient
from tempest.services.nova.json.extensions_client import ExtensionsClient
import tempest.config


Expand Down Expand Up @@ -34,6 +35,11 @@ def __init__(self):
self.config.nova.api_key,
self.config.nova.auth_url,
self.config.nova.tenant_name)
self.extensions_client = ExtensionsClient(self.config,
self.config.nova.username,
self.config.nova.api_key,
self.config.nova.auth_url,
self.config.nova.tenant_name)

else:
#Assuming basic/native authentication
Expand All @@ -53,3 +59,7 @@ def __init__(self):
self.config.nova.username,
self.config.nova.api_key,
self.config.nova.auth_url)
self.extensions_client = ExtensionsClient(self.config,
self.config.nova.username,
self.config.nova.api_key,
self.config.nova.auth_url)
16 changes: 16 additions & 0 deletions tempest/services/nova/json/extensions_client.py
@@ -0,0 +1,16 @@
from tempest.common import rest_client
import json


class ExtensionsClient(object):

def __init__(self, config, username, key, auth_url, tenant_name=None):
self.config = config
self.client = rest_client.RestClient(config, username, key,
auth_url, tenant_name)

def list_extensions(self):
url = 'extensions'
resp, body = self.client.get(url)
body = json.loads(body)
return resp, body
20 changes: 20 additions & 0 deletions tempest/tests/test_extensions.py
@@ -0,0 +1,20 @@
from nose.plugins.attrib import attr
from tempest import openstack
import tempest.config
import unittest2 as unittest


class ExtentionsTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.os = openstack.Manager()
cls.client = cls.os.extensions_client
cls.config = cls.os.config

@attr(type='smoke')
def test_list_extensions(self):
"""List of all extensions"""
resp, extensions = self.client.list_extensions()
self.assertTrue("extensions" in extensions)
self.assertEqual(200, resp.status)

0 comments on commit 20b6bca

Please sign in to comment.