diff --git a/manila/db/api.py b/manila/db/api.py index 6c0a483cee..115aa142e0 100644 --- a/manila/db/api.py +++ b/manila/db/api.py @@ -337,7 +337,7 @@ def share_instances_get_all_by_share_network(context, share_network_id): def share_instances_get_all_by_share(context, share_id): """Returns list of shares that belong to given share.""" - return IMPL.share_instances_get_all_by_share_network(context, share_id) + return IMPL.share_instances_get_all_by_share(context, share_id) def share_instances_get_all_by_consistency_group_id(context, cg_id): @@ -393,14 +393,6 @@ def share_get_all_by_consistency_group_id(context, cg_id, sort_key=sort_key, sort_dir=sort_dir) -def share_get_all_by_share_network(context, share_network_id, filters=None, - sort_key=None, sort_dir=None): - """Returns list of shares that belong to given share network.""" - return IMPL.share_get_all_by_share_network( - context, share_network_id, filters=filters, sort_key=sort_key, - sort_dir=sort_dir) - - def share_get_all_by_share_server(context, share_server_id, filters=None, sort_key=None, sort_dir=None): """Returns all shares with given share server ID.""" @@ -752,20 +744,6 @@ def share_server_get(context, id, session=None): return IMPL.share_server_get(context, id, session=session) -def share_server_get_by_host(context, host, share_net_id, session=None): - """Get share server DB records by host.""" - return IMPL.share_server_get_by_host(context, host, share_net_id, - session=session) - - -def share_server_get_by_host_and_share_net(context, host, share_net_id, - session=None): - """Get share server DB records by host and share net.""" - return IMPL.share_server_get_by_host_and_share_net(context, host, - share_net_id, - session=session) - - def share_server_get_all_by_host_and_share_net_valid(context, host, share_net_id, session=None): @@ -854,11 +832,6 @@ def share_type_access_remove(context, type_id, project_id): return IMPL.share_type_access_remove(context, type_id, project_id) -def share_type_qos_specs_get(context, type_id): - """Get all qos specs for given share type.""" - return IMPL.share_type_qos_specs_get(context, type_id) - - def share_type_destroy(context, id): """Delete a share type.""" return IMPL.share_type_destroy(context, id) diff --git a/manila/tests/db/test_api.py b/manila/tests/db/test_api.py new file mode 100644 index 0000000000..b0148dc416 --- /dev/null +++ b/manila/tests/db/test_api.py @@ -0,0 +1,54 @@ +# Copyright (c) Goutham Pacha Ravi. +# All Rights Reserved. +# +# 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. +"""Unit Tests for the interface methods in the manila/db/api.py.""" + +import re + +from manila.db import api as db_interface +from manila.db.sqlalchemy import api as db_api +from manila import test + + +class DBInterfaceTestCase(test.TestCase): + """Test cases for the DB Interface methods.""" + + def setUp(self): + super(self.__class__, self).setUp() + + def test_interface_methods(self): + """Ensure that implementation methods match interfaces. + + manila/db/api module is merely shim layer between the database + implementation and the other methods using these implementations. + Bugs are introduced when the shims go out of sync with the actual + implementation. So this test ensures that method names and + signatures match between the interface and the implementation. + """ + members = dir(db_interface) + # Ignore private methods for the file and any other members that + # need not match. + ignore_members = re.compile(r'^_|CONF|IMPL') + interfaces = [i for i in members if not ignore_members.match(i)] + for interface in interfaces: + method = getattr(db_interface, interface) + if callable(method): + mock_method_call = self.mock_object(db_api, interface) + # kwargs always specify defaults, ignore them in the signature. + args = filter( + lambda x: x != 'kwargs', method.__code__.co_varnames) + + method(*args) + + self.assertTrue(mock_method_call.called)