Throw a skiptest exception to indicate a unittest skip reason

This commit is contained in:
Hanzhang Zeng (Roger) 2019-03-26 15:27:44 -07:00
Родитель efdae81c10
Коммит c3ec1158d9
6 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -27,10 +27,12 @@ class TestArtifactManager(unittest.TestCase):
def test_list_artifacts(self):
artifacts = self.artifact_manager.list_artifacts(build_id="1")
if artifacts:
# If the user is using the devops build manager to make builds there should only be one artifact
# called drop as a result of running the builder commands.
self.assertEqual(artifacts[0].name, 'drop')
if not artifacts:
raise unittest.SkipTest("The build pipeline has no artifacts")
# If the user is using the devops build manager to make builds there should only be one artifact
# called drop as a result of running the builder commands.
self.assertEqual(artifacts[0].name, 'drop')
def test_invalid_list_artifacts_negative_build_id(self):
artifacts = self.artifact_manager.list_artifacts(build_id="-1")

Просмотреть файл

@ -42,7 +42,7 @@ class TestBuilderManager(unittest.TestCase):
# Skip if definition already exists
if self._build_definition_name in [d.name for d in definitions]:
return
raise unittest.SkipTest("Build definition exists. No need to create a new build definition.")
definition = self.builder_manager.create_definition(self._build_definition_name, "Default")
self.assertEqual(definition.name, self._build_definition_name)

Просмотреть файл

@ -75,7 +75,7 @@ class TestOrganizationManager(unittest.TestCase):
# If the organization exists, we will skip this test
if ORGANIZATION_NAME in existing_organization_names:
return
raise unittest.SkipTest("Organization already exists. No need to create a new organization.")
result = self.organization_manager.create_organization('CUS', ORGANIZATION_NAME)
self.assertIsNotNone(result.id)
@ -88,7 +88,7 @@ class TestOrganizationManager(unittest.TestCase):
# If there is no existing organization, we will skip this test
if existing_organization_names.count == 0:
return
raise unittest.SkipTest("There is no existing organization. Cannot create a duplicate.")
organization_name = existing_organization_names[0]
with self.assertRaises(HttpOperationError):

Просмотреть файл

@ -34,7 +34,7 @@ class TestProjectManager(unittest.TestCase):
# If the project exists, we will skip this test
if PROJECT_NAME in existing_project_names:
return
raise unittest.SkipTest("Project already exists. No need to create a new project.")
result = self.project_manager.create_project(PROJECT_NAME)
self.assertIsNotNone(result.id)
@ -47,7 +47,7 @@ class TestProjectManager(unittest.TestCase):
# If no project exists, we will skip this test
if len(existing_project_names) == 0:
return
raise unittest.SkipTest("There is no existing project. Cannot create a duplicate.")
result = self.project_manager.create_project(existing_project_names[0])
self.assertFalse(result.valid)

Просмотреть файл

@ -51,12 +51,12 @@ class TestReleaseManager(unittest.TestCase):
# Skip if service endpoint does not exist
if service_endpoint_name is None:
return
raise unittest.SkipTest("There is no service endpoint. Cannot create release definition.")
# Skip if release definition already exists
definitions = self.release_manager.list_release_definitions()
if self._release_definition_name in [d.name for d in definitions]:
return
raise unittest.SkipTest("The release definition exists. No need to create one.")
new_definition = self.release_manager.create_release_definition(
build_name=self._build_definition_name,
@ -80,7 +80,7 @@ class TestReleaseManager(unittest.TestCase):
# Skip if release definition does not exist
definitions = self.release_manager.list_release_definitions()
if not self._release_definition_name in [d.name for d in definitions]:
return
raise unittest.SkipTest("There is no release definition. Cannot create a new release.")
release = self.release_manager.create_release(self._release_definition_name)
self.assertIsNotNone(release)

Просмотреть файл

@ -50,7 +50,7 @@ class TestServiceEndpointManager(unittest.TestCase):
# Skip if endpoint exists
if len(existing_endpoints) > 0:
return
raise unittest.SkipTest("Service endpoint does not exist")
# Skip if role assignment permission is not granted
try: