From cd62190c35b6aba3b2bb6c4082f09412ea0d9b78 Mon Sep 17 00:00:00 2001 From: Sergey Murashov Date: Tue, 25 Mar 2014 17:42:26 +0400 Subject: [PATCH] Add repository API tests Change-Id: I7cd0e2f6164facf70a9ffce56dc215955a82be83 --- contrib/devstack/extras.d/70-murano.sh | 13 --- functionaltests/api/base.py | 40 ++++++++++ functionaltests/api/v1/test_repository.py | 97 +++++++++++++++++++++++ 3 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 functionaltests/api/v1/test_repository.py diff --git a/contrib/devstack/extras.d/70-murano.sh b/contrib/devstack/extras.d/70-murano.sh index 0aa34886..df22e2a2 100644 --- a/contrib/devstack/extras.d/70-murano.sh +++ b/contrib/devstack/extras.d/70-murano.sh @@ -4,33 +4,20 @@ if is_service_enabled murano; then if [[ "$1" == "source" ]]; then # Initial source source $TOP_DIR/lib/murano - source $TOP_DIR/lib/murano-dashboard elif [[ "$1" == "stack" && "$2" == "install" ]]; then echo_summary "Installing Murano" install_murano - if is_service_enabled horizon; then - install_murano_dashboard - fi elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then echo_summary "Configuring Murano" configure_murano create_murano_accounts - if is_service_enabled horizon; then - configure_murano_dashboard - fi elif [[ "$1" == "stack" && "$2" == "extra" ]]; then echo_summary "Initializing Murano" init_murano - if is_service_enabled horizon; then - init_murano_dashboard - fi start_murano fi if [[ "$1" == "unstack" ]]; then stop_murano - if is_service_enabled horizon; then - cleanup_murano_dashboard - fi fi fi diff --git a/functionaltests/api/base.py b/functionaltests/api/base.py index b0ca0327..15ae0870 100644 --- a/functionaltests/api/base.py +++ b/functionaltests/api/base.py @@ -131,6 +131,46 @@ class MuranoClient(rest_client.RestClient): return resp, json.loads(body) + def get_list_packages(self): + resp, body = self.get('catalog/packages') + + return resp, json.loads(body) + + def get_package(self, id): + resp, body = self.get('catalog/packages/{0}'.format(id)) + + return resp, json.loads(body) + + def update_package(self, id): + post_body = [ + { + "op": "add", + "path": "/tags", + "value": ["i'm a test"] + } + ] + + resp, body = self.patch('catalog/packages/{0}'.format(id), post_body) + + return resp, json.loads(body) + + def delete_package(self, id): + return self.delete('catalog/packages/{0}'.format(id)) + + def download_package(self, id): + return self.get('catalog/packages/{0}/download'.format(id)) + + def get_ui_definition(self, id): + return self.get('catalog/packages/{0}/ui'.format(id)) + + def get_logo(self, id): + return self.get('catalog/packages/{0}/logo'.format(id)) + + def list_categories(self): + resp, body = self.get('catalog/packages/categories') + + return resp, json.loads(body) + class TestCase(testtools.TestCase): @classmethod diff --git a/functionaltests/api/v1/test_repository.py b/functionaltests/api/v1/test_repository.py new file mode 100644 index 00000000..6e12ac30 --- /dev/null +++ b/functionaltests/api/v1/test_repository.py @@ -0,0 +1,97 @@ +# Copyright (c) 2014 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. + +from tempest.test import attr + +from functionaltests.api import base + + +class TestRepository(base.TestCase): + + @classmethod + def setUpClass(cls): + + super(TestRepository, cls).setUpClass() + + raise cls.skipException("Murano Repository tests are disabled") + + @attr(type='smoke') + def test_get_list_packages(self): + resp, body = self.client.get_list_packages() + + self.assertEqual(200, resp.status) + self.assertTrue(isinstance(body['packages'], list)) + + @attr(type='smoke') + def test_get_package(self): + _, body = self.client.get_list_packages() + package = body['packages'][0] + + resp, body = self.client.get_package(package['id']) + + self.assertEqual(200, resp.status) + self.assertEqual(package, body) + + @attr(type='smoke') + def test_update_package(self): + _, body = self.client.get_list_packages() + package = body['packages'][0] + + resp, body = self.client.update_package(package['id']) + + self.assertEqual(200, resp.status) + self.assertIn("i'm a test", body['tags']) + + @attr(type='smoke') + def test_delete_package(self): + _, body = self.client.get_list_packages() + package = body['packages'][0] + + resp, _ = self.client.delete_package(package['id']) + + self.assertEqual(200, resp.status) + + @attr(type='smoke') + def test_download_package(self): + _, body = self.client.get_list_packages() + package = body['packages'][0] + + resp, _ = self.client.download_package(package['id']) + + self.assertEqual(200, resp.status) + + @attr(type='smoke') + def test_get_ui_definitions(self): + _, body = self.client.get_list_packages() + package = body['packages'][0] + + resp, _ = self.client.get_ui_definition(package['id']) + + self.assertEqual(200, resp.status) + + @attr(type='smoke') + def test_get_logo(self): + _, body = self.client.get_list_packages() + package = body['packages'][0] + + resp, _ = self.client.get_logo(package['id']) + + self.assertEqual(200, resp.status) + + @attr(type='smoke') + def test_get_list_categories(self): + resp, body = self.client.list_categories() + + self.assertEqual(200, resp.status) + self.assertTrue(isinstance(body['categories'], list))