tests: assess prerequisite before doing the actual test (#7040)

This PR skips the tagging tests that fail due an ISO not uploading (which is not part of the functionality being tested)

relates to #7021
This commit is contained in:
dahn 2023-01-12 01:51:37 -08:00 committed by GitHub
parent c1b17d2c42
commit 08d54da938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 43 deletions

View File

@ -19,6 +19,7 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
import unittest
from marvin.lib.utils import cleanup_resources, validateList
from marvin.lib.base import (Tag,
Account,
@ -1068,21 +1069,7 @@ class TestResourceTags(cloudstackTestCase):
# 1. Create a tag on ISO using createTags API
# 2. Delete above created tag using deleteTags API
iso = Iso.create(
self.apiclient,
self.services["iso"],
account=self.account.name,
domainid=self.account.domainid
)
self.debug("ISO created with ID: %s" % iso.id)
list_iso_response = Iso.list(self.apiclient,
id=iso.id)
self.assertEqual(
isinstance(list_iso_response, list),
True,
"Check list response returns a valid list"
)
iso = self.create_iso()
self.debug("Creating a tag for the ISO")
tag = Tag.create(
@ -1841,21 +1828,7 @@ class TestResourceTags(cloudstackTestCase):
)
self.cleanup.append(other_user_account)
iso = Iso.create(
self.apiclient,
self.services["iso"],
account=user_account.name,
domainid=user_account.domainid
)
self.debug("ISO created with ID: %s" % iso.id)
list_iso_response = Iso.list(self.apiclient,
id=iso.id)
self.assertEqual(
isinstance(list_iso_response, list),
True,
"Check list response returns a valid list"
)
iso = self.create_iso()
self.debug("Creating a tag for the ISO")
tag = Tag.create(
@ -1935,20 +1908,8 @@ class TestResourceTags(cloudstackTestCase):
)
self.cleanup.append(user_account)
iso = Iso.create(
self.apiclient,
self.services["iso"],
account=user_account.name,
domainid=user_account.domainid
)
iso = self.create_iso()
list_iso_response = Iso.list(self.apiclient,
id=iso.id)
self.assertEqual(
isinstance(list_iso_response, list),
True,
"Check list response returns a valid list"
)
Tag.create(self.apiclient,
resourceIds=iso.id,
resourceType='ISO',
@ -3074,3 +3035,24 @@ class TestResourceTags(cloudstackTestCase):
"List tags should return empty response"
)
return
def create_iso(self):
try:
iso = Iso.create(
self.apiclient,
self.services["iso"],
account=self.account.name,
domainid=self.account.domainid
)
except:
raise unittest.SkipTest("Cannot register ISO for tagging")
self.cleanup.append(iso)
self.debug("ISO created with ID: %s" % iso.id)
list_iso_response = Iso.list(self.apiclient,
id=iso.id)
if not isinstance(list_iso_response, list):
raise unittest.SkipTest("Registered ISO can not be found/listed for tagging")
return iso