Add categories management test suite to the tempest plugin
- Add categories-related checks to the tempest plugin - Separate negative and positive checks - Update base client class with service management methods - Refactor test implementation and improve code quality - Streamline repository tests Change-Id: If61a63624b0d100fb061ad5a807e8017d703e760 Targets: blueprint migrate-to-tempest-plugin
This commit is contained in:
parent
5f4da6e57d
commit
c62ffc1edc
|
@ -232,3 +232,29 @@ class ApplicationCatalogClient(rest_client.RestClient):
|
|||
resp, body = self.get(uri, headers)
|
||||
self.expected_success(200, resp.status)
|
||||
return self._parse_resp(body)
|
||||
|
||||
# -----------------------------Category methods--------------------------------
|
||||
def list_categories(self):
|
||||
uri = 'v1/catalog/packages/categories'
|
||||
resp, body = self.get(uri)
|
||||
self.expected_success(200, resp.status)
|
||||
return self._parse_resp(body)
|
||||
|
||||
def create_category(self, name):
|
||||
body = {'name': name}
|
||||
uri = 'v1/catalog/categories'
|
||||
resp, body = self.post(uri, json.dumps(body))
|
||||
self.expected_success(200, resp.status)
|
||||
return self._parse_resp(body)
|
||||
|
||||
def delete_category(self, category_id):
|
||||
uri = 'v1/catalog/categories/{0}'.format(category_id)
|
||||
resp, body = self.delete(uri)
|
||||
self.expected_success(200, resp.status)
|
||||
return self._parse_resp(body)
|
||||
|
||||
def get_category(self, category_id):
|
||||
uri = 'v1/catalog/categories/{0}'.format(category_id)
|
||||
resp, body = self.get(uri)
|
||||
self.expected_success(200, resp.status)
|
||||
return self._parse_resp(body)
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
# Copyright (c) 2016 Mirantis, Inc.
|
||||
#
|
||||
# Licensed 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 KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from tempest.test import attr
|
||||
|
||||
from murano_tempest_tests.tests.api.application_catalog import base
|
||||
from murano_tempest_tests import utils
|
||||
|
||||
|
||||
class TestCategories(base.BaseApplicationCatalogIsolatedAdminTest):
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(TestCategories, cls).resource_setup()
|
||||
application_name = utils.generate_name(cls.__name__)
|
||||
cls.abs_archive_path, dir_with_archive, archive_name = \
|
||||
utils.prepare_package(application_name)
|
||||
cls.package = cls.application_catalog_client.upload_package(
|
||||
application_name, archive_name, dir_with_archive,
|
||||
{"categories": [], "tags": [], 'is_public': False})
|
||||
name = utils.generate_name(cls.__name__)
|
||||
cls.category = cls.application_catalog_client.create_category(name)
|
||||
|
||||
@classmethod
|
||||
def resource_cleanup(cls):
|
||||
os.remove(cls.abs_archive_path)
|
||||
cls.application_catalog_client.delete_package(cls.package['id'])
|
||||
cls.application_catalog_client.delete_category(cls.category['id'])
|
||||
super(TestCategories, cls).resource_cleanup()
|
||||
|
||||
@attr(type='smoke')
|
||||
def test_get_list_categories(self):
|
||||
categories_list = self.application_catalog_client.list_categories()
|
||||
self.assertIsInstance(categories_list, list)
|
||||
|
||||
@attr(type='smoke')
|
||||
def test_create_and_delete_category(self):
|
||||
name = utils.generate_name('create_and_delete_category')
|
||||
categories_list = self.application_catalog_client.list_categories()
|
||||
self.assertNotIn(name, categories_list)
|
||||
category = self.application_catalog_client.create_category(name)
|
||||
self.assertEqual(name, category['name'])
|
||||
categories_list = self.application_catalog_client.list_categories()
|
||||
self.assertIn(name, categories_list)
|
||||
self.application_catalog_client.delete_category(category['id'])
|
||||
categories_list = self.application_catalog_client.list_categories()
|
||||
self.assertNotIn(name, categories_list)
|
||||
|
||||
@attr(type='smoke')
|
||||
def test_get_category(self):
|
||||
category = self.application_catalog_client.get_category(
|
||||
self.category['id'])
|
||||
self.assertEqual(self.category['id'], category['id'])
|
||||
self.assertEqual(self.category['name'], category['name'])
|
||||
|
||||
@attr(type='smoke')
|
||||
def test_add_package_to_new_category_and_remove_it_from_category(self):
|
||||
category = self.application_catalog_client.get_category(
|
||||
self.category['id'])
|
||||
self.assertEqual(0, category['package_count'])
|
||||
|
||||
post_body = [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/categories",
|
||||
"value": [category['name']]
|
||||
}
|
||||
]
|
||||
|
||||
package = self.application_catalog_client.update_package(
|
||||
self.package['id'], post_body)
|
||||
self.assertIn(self.category['name'], package['categories'])
|
||||
category = self.application_catalog_client.get_category(
|
||||
self.category['id'])
|
||||
self.assertEqual(1, category['package_count'])
|
||||
self.assertEqual(1, len(category['packages']))
|
||||
|
||||
post_body = [
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/categories",
|
||||
"value": [category['name']]
|
||||
}
|
||||
]
|
||||
|
||||
package = self.application_catalog_client.update_package(
|
||||
self.package['id'], post_body)
|
||||
self.assertNotIn(self.category['name'], package['categories'])
|
||||
category = self.application_catalog_client.get_category(
|
||||
self.category['id'])
|
||||
self.assertEqual(0, category['package_count'])
|
||||
self.assertEqual(0, len(category['packages']))
|
|
@ -0,0 +1,68 @@
|
|||
# Copyright (c) 2016 Mirantis, Inc.
|
||||
#
|
||||
# Licensed 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 KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from tempest.test import attr
|
||||
from tempest_lib import exceptions
|
||||
|
||||
from murano_tempest_tests.tests.api.application_catalog import base
|
||||
from murano_tempest_tests import utils
|
||||
|
||||
|
||||
class TestCategoriesNegative(base.BaseApplicationCatalogIsolatedAdminTest):
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(TestCategoriesNegative, cls).resource_setup()
|
||||
application_name = utils.generate_name(cls.__name__)
|
||||
name = utils.generate_name(cls.__name__)
|
||||
cls.category = cls.application_catalog_client.create_category(name)
|
||||
cls.abs_archive_path, dir_with_archive, archive_name = \
|
||||
utils.prepare_package(application_name)
|
||||
cls.package = cls.application_catalog_client.upload_package(
|
||||
application_name, archive_name, dir_with_archive,
|
||||
{"categories": [cls.category['name']],
|
||||
"tags": [], 'is_public': False})
|
||||
|
||||
@classmethod
|
||||
def resource_cleanup(cls):
|
||||
os.remove(cls.abs_archive_path)
|
||||
cls.application_catalog_client.delete_package(cls.package['id'])
|
||||
cls.application_catalog_client.delete_category(cls.category['id'])
|
||||
super(TestCategoriesNegative, cls).resource_cleanup()
|
||||
|
||||
@attr(type='negative')
|
||||
def test_delete_category_by_incorrect_id(self):
|
||||
self.assertRaises(exceptions.NotFound,
|
||||
self.application_catalog_client.delete_category,
|
||||
utils.generate_uuid())
|
||||
|
||||
@attr(type='negative')
|
||||
def test_get_category_by_incorrect_id(self):
|
||||
self.assertRaises(exceptions.NotFound,
|
||||
self.application_catalog_client.get_category,
|
||||
utils.generate_uuid())
|
||||
|
||||
@attr(type='negative')
|
||||
def test_create_category_with_same_name(self):
|
||||
self.assertRaises(exceptions.Conflict,
|
||||
self.application_catalog_client.create_category,
|
||||
self.category['name'])
|
||||
|
||||
@attr(type='negative')
|
||||
def test_delete_category_with_package(self):
|
||||
self.assertRaises(exceptions.Forbidden,
|
||||
self.application_catalog_client.delete_category,
|
||||
self.category['id'])
|
|
@ -20,7 +20,7 @@ from murano_tempest_tests.tests.api.application_catalog import base
|
|||
from murano_tempest_tests import utils
|
||||
|
||||
|
||||
class TestRepositorySanity(base.BaseApplicationCatalogIsolatedAdminTest):
|
||||
class TestRepositorySanity(base.BaseApplicationCatalogTest):
|
||||
|
||||
@attr(type='smoke')
|
||||
def test_get_list_packages(self):
|
||||
|
@ -46,7 +46,7 @@ class TestRepositorySanity(base.BaseApplicationCatalogIsolatedAdminTest):
|
|||
self.assertEqual(len(packages_list), len(updated_packages_list))
|
||||
|
||||
|
||||
class TestRepository(base.BaseApplicationCatalogAdminTest):
|
||||
class TestRepository(base.BaseApplicationCatalogIsolatedAdminTest):
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
|
|
|
@ -21,7 +21,7 @@ from murano_tempest_tests.tests.api.application_catalog import base
|
|||
from murano_tempest_tests import utils
|
||||
|
||||
|
||||
class TestRepositoryNegativeNotFound(base.BaseApplicationCatalogAdminTest):
|
||||
class TestRepositoryNegativeNotFound(base.BaseApplicationCatalogTest):
|
||||
|
||||
@attr(type='negative')
|
||||
def test_update_package_with_incorrect_id(self):
|
||||
|
@ -69,7 +69,7 @@ class TestRepositoryNegativeNotFound(base.BaseApplicationCatalogAdminTest):
|
|||
utils.generate_uuid())
|
||||
|
||||
|
||||
class TestRepositoryNegativeForbidden(base.BaseApplicationCatalogAdminTest):
|
||||
class TestRepositoryNegativeForbidden(base.BaseApplicationCatalogTest):
|
||||
|
||||
# TODO(freerunner): I hope, that we can setup and cleanup resources
|
||||
# TODO(freerunner): dramatically better.
|
||||
|
|
Loading…
Reference in New Issue