Adding some new flavors tests
This commit is contained in:
		@@ -18,16 +18,18 @@ import os
 | 
			
		||||
from nose.tools import assert_equal
 | 
			
		||||
from nose.tools import assert_false
 | 
			
		||||
from nose.tools import assert_true
 | 
			
		||||
from novaclient import exceptions as nova_exceptions
 | 
			
		||||
 | 
			
		||||
from proboscis import before_class
 | 
			
		||||
from proboscis import test
 | 
			
		||||
from proboscis.asserts import assert_raises
 | 
			
		||||
 | 
			
		||||
import tests
 | 
			
		||||
from tests.util import create_dbaas_client
 | 
			
		||||
from tests.util import create_nova_client
 | 
			
		||||
from tests.util import test_config
 | 
			
		||||
from tests.util.users import Requirements
 | 
			
		||||
 | 
			
		||||
from tests.util.check import AttrCheck
 | 
			
		||||
 | 
			
		||||
GROUP = "dbaas.api.flavors"
 | 
			
		||||
 | 
			
		||||
@@ -119,3 +121,29 @@ class Flavors(object):
 | 
			
		||||
            assert_false(found_index is None, msg)
 | 
			
		||||
        for flavor in dbaas_flavors:
 | 
			
		||||
            assert_link_list_is_equal(flavor)
 | 
			
		||||
 | 
			
		||||
    @test
 | 
			
		||||
    def test_flavor_list_attrs(self):
 | 
			
		||||
        expected_attrs =['id', 'name', 'ram', 'links']
 | 
			
		||||
        flavors = self.rd_client.flavors.list()
 | 
			
		||||
        attrcheck = AttrCheck()
 | 
			
		||||
        for flavor in flavors:
 | 
			
		||||
            flavor_dict = flavor._info
 | 
			
		||||
            attrcheck.attrs_exist(flavor_dict, expected_attrs,
 | 
			
		||||
                                  msg="Flavors list")
 | 
			
		||||
            attrcheck.links(flavor_dict['links'])
 | 
			
		||||
 | 
			
		||||
    @test
 | 
			
		||||
    def test_flavor_get_attrs(self):
 | 
			
		||||
        expected_attrs =['id', 'name', 'ram', 'links']
 | 
			
		||||
        flavor = self.rd_client.flavors.get(1)
 | 
			
		||||
        attrcheck = AttrCheck()
 | 
			
		||||
        flavor_dict = flavor._info
 | 
			
		||||
        attrcheck.attrs_exist(flavor_dict, expected_attrs,
 | 
			
		||||
                              msg="Flavor Get 1")
 | 
			
		||||
        attrcheck.links(flavor_dict['links'])
 | 
			
		||||
 | 
			
		||||
    @test
 | 
			
		||||
    def test_flavor_not_found(self):
 | 
			
		||||
        assert_raises(nova_exceptions.NotFound,
 | 
			
		||||
                      self.rd_client.flavors.get, "detail")
 | 
			
		||||
 
 | 
			
		||||
@@ -60,6 +60,7 @@ from tests.util import process
 | 
			
		||||
from tests.util.users import Requirements
 | 
			
		||||
from tests.util import string_in_list
 | 
			
		||||
from tests.util import poll_until
 | 
			
		||||
from tests.util.check import AttrCheck
 | 
			
		||||
from tests import TEST_MGMT
 | 
			
		||||
from tests import WHITE_BOX
 | 
			
		||||
 | 
			
		||||
@@ -841,27 +842,13 @@ class VerifyInstanceMgmtInfo(object):
 | 
			
		||||
            assert_true('name' in user, "'name' not in users element.")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CheckInstance(Check):
 | 
			
		||||
class CheckInstance(AttrCheck):
 | 
			
		||||
    """Class to check various attributes of Instance details"""
 | 
			
		||||
 | 
			
		||||
    def __init__(self, instance):
 | 
			
		||||
        super(CheckInstance, self).__init__()
 | 
			
		||||
        self.instance = instance
 | 
			
		||||
 | 
			
		||||
    def fail(self, msg):
 | 
			
		||||
        self.true(False, msg)
 | 
			
		||||
 | 
			
		||||
    def attrs_exist(self, list, expected_attrs, msg=None):
 | 
			
		||||
        # Check these attrs only are returned in create response
 | 
			
		||||
        for attr in list:
 | 
			
		||||
            if attr not in expected_attrs:
 | 
			
		||||
                self.fail("%s should not contain '%s'" % (msg, attr))
 | 
			
		||||
 | 
			
		||||
    def links(self, links):
 | 
			
		||||
        expected_attrs = ['href', 'rel']
 | 
			
		||||
        for link in links:
 | 
			
		||||
            self.attrs_exist(link, expected_attrs, msg="Links")
 | 
			
		||||
 | 
			
		||||
    def flavor(self):
 | 
			
		||||
        if 'flavor' not in self.instance:
 | 
			
		||||
            self.fail("'flavor' not found in instance.")
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ from proboscis.asserts import assert_equal
 | 
			
		||||
from proboscis.asserts import assert_false
 | 
			
		||||
from proboscis.asserts import assert_not_equal
 | 
			
		||||
from proboscis.asserts import assert_true
 | 
			
		||||
from proboscis.asserts import Check
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_stack_trace_of_caller(level_up):
 | 
			
		||||
@@ -103,3 +104,24 @@ class Checker(object):
 | 
			
		||||
 | 
			
		||||
    def true(self, *args, **kwargs):
 | 
			
		||||
        self._run_assertion(assert_true, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class AttrCheck(Check):
 | 
			
		||||
    """Class for attr checks, links and other common items."""
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        super(AttrCheck, self).__init__()
 | 
			
		||||
 | 
			
		||||
    def fail(self, msg):
 | 
			
		||||
        self.true(False, msg)
 | 
			
		||||
 | 
			
		||||
    def attrs_exist(self, list, expected_attrs, msg=None):
 | 
			
		||||
        # Check these attrs only are returned in create response
 | 
			
		||||
        for attr in list:
 | 
			
		||||
            if attr not in expected_attrs:
 | 
			
		||||
                self.fail("%s should not contain '%s'" % (msg, attr))
 | 
			
		||||
 | 
			
		||||
    def links(self, links):
 | 
			
		||||
        expected_attrs = ['href', 'rel']
 | 
			
		||||
        for link in links:
 | 
			
		||||
            self.attrs_exist(link, expected_attrs, msg="Links")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user