You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ga...@apache.org on 2015/05/06 13:01:14 UTC

[3/4] git commit: updated refs/heads/master to 6c3dc15

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6c3dc15f/test/integration/component/test_projects.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py
index cacb5a4..e38bccc 100644
--- a/test/integration/component/test_projects.py
+++ b/test/integration/component/test_projects.py
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,94 +16,104 @@
 # under the License.
 """ P1 tests for Project
 """
-#Import Local Modules
-import marvin
+# Import Local Modules
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
-from marvin.sshClient import SshClient
-import datetime
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             ServiceOffering,
+                             Project,
+                             VirtualMachine,
+                             Volume,
+                             DiskOffering,
+                             Configurations,
+                             Domain)
+from marvin.lib.common import (get_domain,
+                               get_zone,
+                               get_template,
+                               list_configurations)
+import time
 
 
 class Services:
+
     """Test Project Services
     """
 
     def __init__(self):
         self.services = {
-                        "domain": {
-                                   "name": "Domain",
-                        },
-                        "project": {
-                                    "name": "Project",
-                                    "displaytext": "Test project",
-                        },
-                         "mgmt_server": {
-                                   "ipaddress": '192.168.100.21',
-                                   "username": 'root',
-                                   "password": 'password',
-                                   "port": 22,
-                        },
-                        "account": {
-                                    "email": "administrator@clogeny.com",
-                                    "firstname": "Test",
-                                    "lastname": "User",
-                                    "username": "test",
-                                    # Random characters are appended for unique
-                                    # username
-                                    "password": "password",
-                         },
-                         "user": {
-                                    "email": "administrator@clogeny.com",
-                                    "firstname": "User",
-                                    "lastname": "User",
-                                    "username": "User",
-                                    # Random characters are appended for unique
-                                    # username
-                                    "password": "password",
-                         },
-                        "disk_offering": {
-                                    "displaytext": "Tiny Disk Offering",
-                                    "name": "Tiny Disk Offering",
-                                    "disksize": 1
-                        },
-                        "volume": {
-                                "diskname": "Test Volume",
-                        },
-                        "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,    # in MHz
+            "domain": {
+                "name": "Domain",
+            },
+            "project": {
+                "name": "Project",
+                "displaytext": "Test project",
+            },
+            "mgmt_server": {
+                "ipaddress": '192.168.100.21',
+                "username": 'root',
+                "password": 'password',
+                "port": 22,
+            },
+            "account": {
+                "email": "administrator@clogeny.com",
+                "firstname": "Test",
+                "lastname": "User",
+                "username": "test",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+            },
+            "user": {
+                "email": "administrator@clogeny.com",
+                "firstname": "User",
+                "lastname": "User",
+                "username": "User",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+            },
+            "disk_offering": {
+                "displaytext": "Tiny Disk Offering",
+                "name": "Tiny Disk Offering",
+                "disksize": 1
+            },
+            "volume": {
+                "diskname": "Test Volume",
+            },
+            "service_offering": {
+                "name": "Tiny Instance",
+                "displaytext": "Tiny Instance",
+                "cpunumber": 1,
+                "cpuspeed": 100,    # in MHz
                                     "memory": 128,       # In MBs
-                        },
-                        "virtual_machine": {
-                                    "displayname": "Test VM",
-                                    "username": "root",
-                                    "password": "password",
-                                    "ssh_port": 22,
-                                    "hypervisor": 'XenServer',
-                                    # Hypervisor type should be same as
-                                    # hypervisor type of cluster
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": 'TCP',
-                         },
-                        "ostype": 'CentOS 5.3 (64-bit)',
-                        # Cent OS 5.3 (64 bit)
-                        "sleep": 60,
-                        "timeout": 10,
-                    }
+            },
+            "virtual_machine": {
+                "displayname": "Test VM",
+                "username": "root",
+                "password": "password",
+                "ssh_port": 22,
+                "hypervisor": 'XenServer',
+                # Hypervisor type should be same as
+                # hypervisor type of cluster
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            # Cent OS 5.3 (64 bit)
+            "sleep": 60,
+            "timeout": 10,
+        }
 
 
 class TestMultipleProjectCreation(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.testClient = super(TestMultipleProjectCreation, cls).getClsTestClient()
+        cls.testClient = super(
+            TestMultipleProjectCreation,
+            cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
 
         cls.services = Services().services
@@ -111,38 +121,38 @@ class TestMultipleProjectCreation(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
-
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.account)
 
         cls.user = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
-
-        cls._cleanup = [cls.account, cls.user]
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.user)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -152,17 +162,28 @@ class TestMultipleProjectCreation(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_01_create_multiple_projects_by_account(self):
         """ Verify an account can own multiple projects and can belong to multiple projects
         """
@@ -174,139 +195,142 @@ class TestMultipleProjectCreation(cloudstackTestCase):
 
         # Create project as a domain admin
         project_1 = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.cleanup.append(project_1)
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project_1.id)
+                   project_1.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project_1.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project_1.id,
+            listall=True
+        )
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project_1.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project_1.name,
+            list_project.name,
+            "Check project name from list response"
+        )
         # Create another project as a domain admin
         project_2 = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.cleanup.append(project_2)
         self.debug("Created project with domain user with ID: %s" %
-                                                            project_2.id)
+                   project_2.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project_2.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project_2.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                        len(list_projects_reponse),
-                        0,
-                        "Check list project response returns a valid project"
-                        )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assert_(isinstance(self.user.user, list))
-        self.assert_(len(self.user.user) > 0, msg="Account %s has no users" % self.user.name)
-        self.debug("Adding account %s to project with email %s" % (self.user.name, self.user.user[0].email))
+        self.assert_(len(self.user.user) > 0,
+                     msg="Account %s has no users" % self.user.name)
+        self.debug(
+            "Adding account %s to project with email %s" %
+            (self.user.name, self.user.user[0].email))
         email = self.user.user[0].email
 
         # Add user to the project
         project_1.addAccount(
-                           self.apiclient,
-                           self.user.name,
-                           email
-                           )
+            self.apiclient,
+            self.user.name,
+            email
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_response = Project.listAccounts(
-                                            self.apiclient,
-                                            projectid=project_1.id,
-                                            account=self.user.name,
-                                            )
+            self.apiclient,
+            projectid=project_1.id,
+            account=self.user.name,
+        )
         self.debug(accounts_response)
         self.assertEqual(
-                            isinstance(accounts_response, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_response, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_response[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         # Add user to the project
         project_2.addAccount(
-                           self.apiclient,
-                           self.user.name,
-                           email
-                           )
+            self.apiclient,
+            self.user.name,
+            email
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_response = Project.listAccounts(
-                                            self.apiclient,
-                                            projectid=project_2.id,
-                                            account=self.user.name,
-                                            )
+            self.apiclient,
+            projectid=project_2.id,
+            account=self.user.name,
+        )
         self.debug(accounts_response)
         self.assertEqual(
-                            isinstance(accounts_response, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_response, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_response[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         return
 
 
@@ -314,7 +338,9 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.testClient = super(TestCrossDomainAccountAdd, cls).getClsTestClient()
+        cls.testClient = super(
+            TestCrossDomainAccountAdd,
+            cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
 
         cls.services = Services().services
@@ -323,43 +349,44 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         # Create domains, account etc.
         cls.new_domain = Domain.create(
-                                   cls.api_client,
-                                   cls.services["domain"]
-                                   )
+            cls.api_client,
+            cls.services["domain"]
+        )
 
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.account)
 
         cls.user = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.new_domain.id
-                            )
-
-        cls._cleanup = [cls.account, cls.user]
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.new_domain.id
+        )
+        cls._cleanup.append(cls.user)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -369,17 +396,28 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_02_cross_domain_account_add(self):
         """ Verify No cross domain projects
         """
@@ -390,52 +428,52 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.cleanup.append(project)
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
 
         self.debug("Adding user: %s from domain: %s to project: %s" % (
-                                                    self.user.name,
-                                                    self.user.domainid,
-                                                    project.id
-                                                    ))
+            self.user.name,
+            self.user.domainid,
+            project.id
+        ))
         with self.assertRaises(Exception):
             # Add user to the project from different domain
             project.addAccount(
-                           self.apiclient,
-                           self.user.name
-                           )
+                self.apiclient,
+                self.user.name
+            )
             self.debug("User add to project failed!")
         return
 
@@ -444,7 +482,9 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.testClient = super(TestDeleteAccountWithProject, cls).getClsTestClient()
+        cls.testClient = super(
+            TestDeleteAccountWithProject,
+            cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
 
         cls.services = Services().services
@@ -453,30 +493,31 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         # Create account
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
-        cls._cleanup = [cls.account]
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.account)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -486,17 +527,28 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_03_delete_account_with_project(self):
         """ Test As long as the project exists, its owner can't be removed
         """
@@ -507,45 +559,45 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.cleanup.append(project)
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
         # Deleting account who is owner of the project
         with self.assertRaises(Exception):
             self.account.delete(self.apiclient)
             self.debug("Deleting account %s failed!" %
-                                    self.account.name)
+                       self.account.name)
         return
 
 
@@ -553,7 +605,9 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.testClient = super(TestDeleteDomainWithProject, cls).getClsTestClient()
+        cls.testClient = super(
+            TestDeleteDomainWithProject,
+            cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
 
         cls.services = Services().services
@@ -561,35 +615,35 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         # Create account
         cls.domain = Domain.create(
-                                   cls.api_client,
-                                   cls.services["domain"]
-                                   )
+            cls.api_client,
+            cls.services["domain"]
+        )
 
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
-        cls._cleanup = []
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -599,17 +653,28 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_04_delete_domain_with_project(self):
         """ Test Verify delete domain with cleanup=true should delete projects
             belonging to the domain
@@ -621,39 +686,39 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
 
         self.debug("Deleting domain: %s forcefully" % self.domain.name)
         # Delete domain with cleanup=True
@@ -661,31 +726,31 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
         self.debug("Removed domain: %s" % self.domain.name)
 
         interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
+            self.apiclient,
+            name='account.cleanup.interval'
+        )
         self.assertEqual(
-                            isinstance(interval, list),
-                            True,
-                            "Check if account.cleanup.interval config present"
-                        )
+            isinstance(interval, list),
+            True,
+            "Check if account.cleanup.interval config present"
+        )
         self.debug(
-                "Sleep for account cleanup interval: %s" %
-                                                    interval[0].value)
+            "Sleep for account cleanup interval: %s" %
+            interval[0].value)
         # Sleep to ensure that all resources are deleted
         time.sleep(int(interval[0].value))
 
         # Project should be deleted as part of domain cleanup
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
         self.assertEqual(
-                        list_projects_reponse,
-                        None,
-                        "Project should be deleted as part of domain cleanup"
-                        )
+            list_projects_reponse,
+            None,
+            "Project should be deleted as part of domain cleanup"
+        )
         return
 
 
@@ -702,36 +767,38 @@ class TestProjectOwners(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.services['mode'] = cls.zone.networktype
 
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         # Create accounts
         cls.admin = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.admin)
         cls.new_admin = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
-        cls._cleanup = [cls.admin, cls.new_admin]
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.new_admin)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -741,17 +808,28 @@ class TestProjectOwners(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_05_user_project_owner_promotion(self):
         """ Test Verify a project user can be later promoted to become a
             owner
@@ -764,136 +842,144 @@ class TestProjectOwners(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.admin.name,
-                                 domainid=self.admin.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.admin.name,
+            domainid=self.admin.domainid
+        )
         self.cleanup.append(project)
         # Cleanup created project at end of test
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
         self.debug("Adding %s user to project: %s" % (
-                                                self.new_admin.name,
-                                                project.name
-                                                ))
+            self.new_admin.name,
+            project.name
+        ))
         # Add user to the project
         project.addAccount(
-                           self.apiclient,
-                           self.new_admin.name,
-                           )
+            self.apiclient,
+            self.new_admin.name,
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.new_admin.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.new_admin.name,
+        )
         self.debug(accounts_reponse)
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
 
         # Update the project with new admin
         project.update(
-                       self.apiclient,
-                       account=self.new_admin.name
-                       )
+            self.apiclient,
+            account=self.new_admin.name
+        )
 
         # listProjectAccount to verify the user is new admin of the project
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.new_admin.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.new_admin.name,
+        )
         self.debug(accounts_reponse)
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Admin',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Admin',
+            "Newly added user is not added as a regular user"
+        )
 
         # listProjectAccount to verify old user becomes a regular user
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.admin.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.admin.name,
+        )
         self.debug(accounts_reponse)
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_06_max_one_project_owner(self):
         """ Test Verify there can only be one owner of a project at a time
         """
@@ -905,211 +991,211 @@ class TestProjectOwners(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.admin.name,
-                                 domainid=self.admin.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.admin.name,
+            domainid=self.admin.domainid
+        )
         # Cleanup created project at end of test
         self.cleanup.append(project)
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
         self.user = Account.create(
-                              self.apiclient,
-                              self.services["account"],
-                              admin=True,
-                              domainid=self.domain.id
-                              )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup.append(self.user)
         self.debug("Created account with ID: %s" %
-                                                self.user.name)
+                   self.user.name)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
         self.debug("Adding %s user to project: %s" % (
-                                                self.new_admin.name,
-                                                project.name
-                                                ))
+            self.new_admin.name,
+            project.name
+        ))
         # Add user to the project
         project.addAccount(
-                           self.apiclient,
-                           self.new_admin.name,
-                           )
+            self.apiclient,
+            self.new_admin.name,
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.new_admin.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.new_admin.name,
+        )
         self.debug(accounts_reponse)
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         self.debug("Updating project with new Admin: %s" %
-                                                self.new_admin.name)
+                   self.new_admin.name)
         # Update the project with new admin
         project.update(
-                       self.apiclient,
-                       account=self.new_admin.name
-                       )
+            self.apiclient,
+            account=self.new_admin.name
+        )
 
         # listProjectAccount to verify the user is new admin of the project
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.new_admin.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.new_admin.name,
+        )
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Admin',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Admin',
+            "Newly added user is not added as a regular user"
+        )
 
         self.debug("Adding %s user to project: %s" % (
-                                                self.user.name,
-                                                project.name
-                                                ))
+            self.user.name,
+            project.name
+        ))
         # Add user to the project
         project.addAccount(
-                           self.apiclient,
-                           self.user.name,
-                           )
+            self.apiclient,
+            self.user.name,
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.user.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.user.name,
+        )
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
 
         self.debug("Updating project with new Admin: %s" %
-                                                self.user.name)
+                   self.user.name)
 
         # Update the project with new admin
         project.update(
-                       self.apiclient,
-                       account=self.user.name
-                       )
+            self.apiclient,
+            account=self.user.name
+        )
 
         # listProjectAccount to verify the user is new admin of the project
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.user.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.user.name,
+        )
         self.debug(accounts_reponse)
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Admin',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Admin',
+            "Newly added user is not added as a regular user"
+        )
 
        # listProjectAccount to verify old user becomes a regular user
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.new_admin.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.new_admin.name,
+        )
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         return
 
 
@@ -1126,41 +1212,43 @@ class TestProjectResources(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.services['mode'] = cls.zone.networktype
 
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         # Create account, disk offering etc.
         cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
-                                    cls.services["disk_offering"]
-                                    )
+            cls.api_client,
+            cls.services["disk_offering"]
+        )
+        cls._cleanup.append(cls.disk_offering)
 
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.account)
         cls.user = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
-        cls._cleanup = [cls.account, cls.disk_offering]
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1170,17 +1258,28 @@ class TestProjectResources(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_07_project_resources_account_delete(self):
         """ Test Verify after an account is removed from the project, all its resources stay with the project.
         """
@@ -1192,82 +1291,82 @@ class TestProjectResources(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.cleanup.append(project)
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
         self.debug("Adding %s user to project: %s" % (
-                                                self.user.name,
-                                                project.name
-                                                ))
+            self.user.name,
+            project.name
+        ))
         # Add user to the project
         project.addAccount(
-                           self.apiclient,
-                           self.user.name,
-                           )
+            self.apiclient,
+            self.user.name,
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_response = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.user.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.user.name,
+        )
         self.assertEqual(
-                            isinstance(accounts_response, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_response, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_response[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         # Create some resources(volumes) for the projects
         volume = Volume.create(
-                               self.apiclient,
-                               self.services["volume"],
-                               zoneid=self.zone.id,
-                               diskofferingid=self.disk_offering.id,
-                               projectid=project.id
-                               )
+            self.apiclient,
+            self.services["volume"],
+            zoneid=self.zone.id,
+            diskofferingid=self.disk_offering.id,
+            projectid=project.id
+        )
 
         # Delete the project user ie the account
         self.user.delete(self.apiclient)
@@ -1275,26 +1374,34 @@ class TestProjectResources(cloudstackTestCase):
         volumes = Volume.list(self.apiclient, id=volume.id)
 
         self.assertEqual(
-                            isinstance(volumes, list),
-                            True,
-                            "Check for a valid list volumes response"
-                            )
+            isinstance(volumes, list),
+            True,
+            "Check for a valid list volumes response"
+        )
 
         self.assertNotEqual(
-                    len(volumes),
-                    0,
-                    "Check list volumes API response returns a valid list"
-                    )
+            len(volumes),
+            0,
+            "Check list volumes API response returns a valid list"
+        )
         volume_response = volumes[0]
 
         self.assertEqual(
-                         volume_response.name,
-                         volume.name,
-                         "Volume should exist after project user deletion."
-                        )
+            volume_response.name,
+            volume.name,
+            "Volume should exist after project user deletion."
+        )
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_08_cleanup_after_project_delete(self):
         """ Test accounts are unassigned from project after project deletion
         """
@@ -1307,92 +1414,92 @@ class TestProjectResources(cloudstackTestCase):
 
         # Create project as a domain admin
         project = Project.create(
-                                 self.apiclient,
-                                 self.services["project"],
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
+            self.apiclient,
+            self.services["project"],
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         # Cleanup created project at end of test
         self.debug("Created project with domain admin with ID: %s" %
-                                                                project.id)
+                   project.id)
 
         list_projects_reponse = Project.list(
-                                             self.apiclient,
-                                             id=project.id,
-                                             listall=True
-                                             )
+            self.apiclient,
+            id=project.id,
+            listall=True
+        )
 
         self.assertEqual(
-                            isinstance(list_projects_reponse, list),
-                            True,
-                            "Check for a valid list projects response"
-                            )
+            isinstance(list_projects_reponse, list),
+            True,
+            "Check for a valid list projects response"
+        )
         list_project = list_projects_reponse[0]
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
 
         self.assertEqual(
-                            project.name,
-                            list_project.name,
-                            "Check project name from list response"
-                            )
+            project.name,
+            list_project.name,
+            "Check project name from list response"
+        )
         self.user = Account.create(
-                                   self.apiclient,
-                                   self.services["account"],
-                                   admin=True,
-                                   domainid=self.domain.id
-                                   )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup.append(self.user)
         self.debug("Adding %s user to project: %s" % (
-                                                self.user.name,
-                                                project.name
-                                                ))
+            self.user.name,
+            project.name
+        ))
         # Add user to the project
         project.addAccount(
-                           self.apiclient,
-                           self.user.name
-                           )
+            self.apiclient,
+            self.user.name
+        )
 
         # listProjectAccount to verify the user is added to project or not
         accounts_reponse = Project.listAccounts(
-                                        self.apiclient,
-                                        projectid=project.id,
-                                        account=self.user.name,
-                                        )
+            self.apiclient,
+            projectid=project.id,
+            account=self.user.name,
+        )
         self.assertEqual(
-                            isinstance(accounts_reponse, list),
-                            True,
-                            "Check for a valid list accounts response"
-                            )
+            isinstance(accounts_reponse, list),
+            True,
+            "Check for a valid list accounts response"
+        )
 
         self.assertNotEqual(
-                    len(list_projects_reponse),
-                    0,
-                    "Check list project response returns a valid project"
-                    )
+            len(list_projects_reponse),
+            0,
+            "Check list project response returns a valid project"
+        )
         account = accounts_reponse[0]
 
         self.assertEqual(
-                            account.role,
-                            'Regular',
-                            "Newly added user is not added as a regular user"
-                            )
+            account.role,
+            'Regular',
+            "Newly added user is not added as a regular user"
+        )
         # Create some resources(volumes) for the projects
         volume = Volume.create(
-                               self.apiclient,
-                               self.services["volume"],
-                               zoneid=self.zone.id,
-                               diskofferingid=self.disk_offering.id,
-                               projectid=project.id
-                               )
+            self.apiclient,
+            self.services["volume"],
+            zoneid=self.zone.id,
+            diskofferingid=self.disk_offering.id,
+            projectid=project.id
+        )
         self.debug("Created a volume: %s for project: %s" % (
-                                                             volume.id,
-                                                             project.name
-                                                             ))
+            volume.id,
+            project.name
+        ))
         # Delete the project user
         self.debug("Deleting project: %s" % project.name)
         project.delete(self.apiclient)
@@ -1401,10 +1508,10 @@ class TestProjectResources(cloudstackTestCase):
         volumes = Volume.list(self.apiclient, id=volume.id)
 
         self.assertEqual(
-                    volumes,
-                    None,
-                    "Resources (volume) should be deleted as part of cleanup"
-                    )
+            volumes,
+            None,
+            "Resources (volume) should be deleted as part of cleanup"
+        )
 
         # Accounts should be un-assigned from project,
         # so this call will raise an exception: Unable to find the project id=
@@ -1417,7 +1524,9 @@ class TestProjectSuspendActivate(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.testClient = super(TestProjectSuspendActivate, cls).getClsTestClient()
+        cls.testClient = super(
+            TestProjectSuspendActivate,
+            cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
 
         cls.services = Services().services
@@ -1426,64 +1535,63 @@ class TestProjectSuspendActivate(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.services['mode'] = cls.zone.networktype
         cls.template = get_template(
-                                    cls.api_client,
-                                    cls.zone.id,
-                                    cls.services["ostype"]
-                                    )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+        cls._cleanup = []
+        cls.isGlobalSettingInvalid = False
         configs = Configurations.list(
-                                      cls.api_client,
-                                      name='project.invite.required'
-                                      )
+            cls.api_client,
+            name='project.invite.required'
+        )
 
-        if not isinstance(configs, list):
-            raise unittest.SkipTest("List configurations has no config: project.invite.required")
-        elif (configs[0].value).lower() != 'false':
-            raise unittest.SkipTest("'project.invite.required' should be set to false")
+        if (configs[0].value).lower() != 'false':
+            cls.isGlobalSettingInvalid = True
+            return
 
         # Create account, service offering, disk offering etc.
         cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
-                                    cls.services["disk_offering"]
-                                    )
+            cls.api_client,
+            cls.services["disk_offering"]
+        )
+        cls._cleanup.append(cls.disk_offering)
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"],
-                                            domainid=cls.domain.id
-                                            )
+            cls.api_client,
+            cls.services["service_offering"],
+            domainid=cls.domain.id
+        )
+        cls._cleanup.append(cls.service_offering)
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.user = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            admin=True,
-                            domainid=cls.domain.id
-                            )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
 
         # Create project as a domain admin
         cls.project = Project.create(
-                                 cls.api_client,
-                                 cls.services["project"],
-                                 account=cls.account.name,
-                                 domainid=cls.account.domainid
-                                 )
+            cls.api_client,
+            cls.services["project"],
+            account=cls.account.name,
+            domainid=cls.account.domainid
+        )
+        cls._cleanup.append(cls.project)
+        cls._cleanup.append(cls.account)
+        cls._cleanup.append(cls.user)
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls._cleanup = [
-                        cls.project,
-                        cls.account,
-                        cls.user,
-                        cls.disk_offering,
-                        cls.service_offering
-                        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1493,17 +1601,28 @@ class TestProjectSuspendActivate(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
+
+        if self.isGlobalSettingInvalid:
+            self.skipTest("'project.invite.required' should be set to false")
         return
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created accounts, domains etc
+            # Clean up, terminate the created accounts, domains etc
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+    @attr(
+        tags=[
+            "advanced",
+            "basic",
+            "sg",
+            "eip",
+            "advancedns",
+            "simulator"],
+        required_hardware="false")
     def test_09_project_suspend(self):
         """ Test Verify after an account is removed from the project, all his
             resources stay with the project.
@@ -1515,96 +1634,96 @@ class TestProjectSuspendActivate(cloudstackTestCase):
         #    account deletion.
 
         self.debug("Adding %s user to project: %s" % (
-                                                self.user.name,
-                                                self.project.name
-                                                ))
+            self.user.name,
+            self.project.name
+        ))
         # Add user to

<TRUNCATED>