Add repository API tests

Change-Id: I7cd0e2f6164facf70a9ffce56dc215955a82be83
This commit is contained in:
Sergey Murashov 2014-03-25 17:42:26 +04:00
parent dbc6843148
commit cd62190c35
3 changed files with 137 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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))