CLOUDSTACK-7691: Fixed 'Exception not raised' issue in test_project_limits.py

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Gaurav Aradhye 2014-10-09 14:56:34 +05:30 committed by SrikanteswaraRao Talluri
parent 5d37f37436
commit bf7ce74c93

View File

@ -17,16 +17,35 @@
""" P1 tests for Resource limits """ P1 tests for Resource limits
""" """
#Import Local Modules #Import Local Modules
import marvin
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import * from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackAPI import * #from marvin.cloudstackAPI import *
from marvin.lib.utils import * from marvin.lib.utils import (cleanup_resources,
from marvin.lib.base import * validateList)
from marvin.lib.common import * from marvin.lib.base import (Account,
Domain,
Project,
Template,
Snapshot,
Volume,
NetworkOffering,
ServiceOffering,
VirtualMachine,
DiskOffering,
Configurations,
Network,
PublicIPAddress)
from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_snapshots,
list_volumes,
list_configurations,
list_resource_limits,
update_resource_limit
)
from marvin.codes import PASS from marvin.codes import PASS
import datetime import time
class Services: class Services:
"""Test Resource Limits Services """Test Resource Limits Services
@ -525,6 +544,11 @@ class TestResourceLimitsProject(cloudstackTestCase):
cls.services["account"], cls.services["account"],
domainid=cls.domain.id domainid=cls.domain.id
) )
cls.userapiclient = cls.testClient.getUserApiClient(
UserName=cls.account.name,
DomainName=cls.account.domain)
# Create project as a domain admin # Create project as a domain admin
cls.project = Project.create( cls.project = Project.create(
cls.api_client, cls.api_client,
@ -713,7 +737,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
# Exception should be raised for second Public IP # Exception should be raised for second Public IP
with self.assertRaises(Exception): with self.assertRaises(Exception):
public_ip_2 = PublicIPAddress.create( PublicIPAddress.create(
self.apiclient, self.apiclient,
zoneid=virtual_machine_1.zoneid, zoneid=virtual_machine_1.zoneid,
services=self.services["server"], services=self.services["server"],
@ -772,7 +796,6 @@ class TestResourceLimitsProject(cloudstackTestCase):
True, True,
"Check for list volume response return valid data" "Check for list volume response return valid data"
) )
volume = volumes[0]
self.debug("Creating snapshot from volume: %s" % volumes[0].id) self.debug("Creating snapshot from volume: %s" % volumes[0].id)
# Create a snapshot from the ROOTDISK # Create a snapshot from the ROOTDISK
@ -915,7 +938,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
self.debug("Creating template from volume: %s" % volume.id) self.debug("Creating template from volume: %s" % volume.id)
# Create a template from the ROOTDISK # Create a template from the ROOTDISK
template_1 = Template.create( template_1 = Template.create(
self.apiclient, self.userapiclient,
self.services["template"], self.services["template"],
volumeid=volume.id, volumeid=volume.id,
projectid=self.project.id projectid=self.project.id
@ -932,7 +955,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
# Exception should be raised for second template # Exception should be raised for second template
with self.assertRaises(Exception): with self.assertRaises(Exception):
Template.create( Template.create(
self.apiclient, self.userapiclient,
self.services["template"], self.services["template"],
volumeid=volume.id, volumeid=volume.id,
projectid=self.project.id projectid=self.project.id