OpenStack Orchestration (Heat)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.8 KiB

# 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
# 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 collections
from manilaclient import exceptions
import mock
from heat.tests import common
from heat.tests import utils
class ManilaClientPluginTests(common.HeatTestCase):
scenarios = [
def setUp(self):
super(ManilaClientPluginTests, self).setUp()
# mock client and plugin
self.manila_client = mock.MagicMock()
con = utils.dummy_context()
c = con.clients
self.manila_plugin = c.client_plugin('manila')
self.manila_plugin._client = self.manila_client
# prepare list of items to test search
Item = collections.namedtuple('Item', ['id', 'name'])
self.item_list = [
Item(name="unique_name", id="unique_id"),
Item(name="unique_id", id="i_am_checking_that_id_prior"),
Item(name="duplicated_name", id="duplicate_test_one"),
Item(name="duplicated_name", id="duplicate_test_second")]
def test_create(self):
context = utils.dummy_context()
plugin = context.clients.client_plugin('manila')
client = plugin.client()
self.assertEqual('http://server.test:5000/v3', client.client.base_url)
def test_manila_get_method(self):
# set item list as client output
manager = getattr(self.manila_client, self.manager_name)
manager.list.return_value = self.item_list
# test that get_<method_name> is searching correctly
get_method = getattr(self.manila_plugin, self.method_name)
self.assertEqual(get_method("unique_id").name, "unique_name")
self.assertRaises(exceptions.NotFound, get_method, "non_exist")
self.assertRaises(exceptions.NoUniqueMatch, get_method,