Resolve unit test failures from missing keystone data

The unit test data must include manila in the services list returned
from keystone in order for the shares screens to be available for
testing.  The mechanism for injecting this into the testing data was
modelled after the approach used by tuskar ui.
This commit is contained in:
Gary W. Smith 2015-04-16 11:03:55 -07:00
parent 88b2fa46a9
commit ca711e1e18
10 changed files with 126 additions and 6 deletions

View File

@ -17,8 +17,8 @@ import mock
from manila_ui.api import manila as api_manila
from manila_ui.dashboards.project.shares import test_data
from manila_ui.test import helpers as test
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas

View File

@ -25,7 +25,7 @@ import mock
from manila_ui.api import manila as api_manila
from manila_ui.dashboards.project.shares import test_data
from openstack_dashboard.test import helpers as test
from manila_ui.test import helpers as test
SHARE_INDEX_URL = reverse('horizon:project:shares:index')

View File

@ -19,9 +19,9 @@ from neutronclient.client import exceptions
from manila_ui.api import manila as api_manila
from manila_ui.dashboards.project.shares import test_data
from manila_ui.test import helpers as test
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
SHARE_INDEX_URL = reverse('horizon:project:shares:index')

View File

@ -17,7 +17,7 @@ import mock
from manila_ui.api import manila as api_manila
from manila_ui.dashboards.project.shares import test_data
from openstack_dashboard.test import helpers as test
from manila_ui.test import helpers as test
SHARE_INDEX_URL = reverse('horizon:project:shares:index')

View File

@ -17,7 +17,7 @@ import mock
from manila_ui.api import manila as api_manila
from manila_ui.dashboards.project.shares import test_data
from openstack_dashboard.test import helpers as test
from manila_ui.test import helpers as test
SHARE_INDEX_URL = reverse('horizon:project:shares:index')

View File

@ -17,9 +17,9 @@ import mock
from manila_ui.api import manila as api_manila
from manila_ui.dashboards.project.shares import test_data
from manila_ui.test import helpers as test
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas

43
manila_ui/test/helpers.py Normal file
View File

@ -0,0 +1,43 @@
#
# 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 django.utils import unittest
from manila_ui.test.test_data import utils
from openstack_dashboard.test import helpers
def create_stubs(stubs_to_create={}):
return helpers.create_stubs(stubs_to_create)
class ManilaTestsMixin(object):
def _setup_test_data(self):
super(ManilaTestsMixin, self)._setup_test_data()
utils.load_test_data(self)
@unittest.skipIf(os.environ.get('SKIP_UNITTESTS', False),
"The SKIP_UNITTESTS env variable is set.")
class TestCase(ManilaTestsMixin, helpers.TestCase):
pass
class BaseAdminViewTests(ManilaTestsMixin, helpers.BaseAdminViewTests):
pass
class APITestCase(ManilaTestsMixin, helpers.APITestCase):
pass

View File

View File

@ -0,0 +1,26 @@
# 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.
def data(TEST):
# Add manila to the keystone data
TEST.service_catalog.append(
{"type": "share",
"name": "Manila",
"endpoints_links": [],
"endpoints": [
{"region": "RegionOne",
"adminURL": "http://admin.manila.example.com:8786/v1.0",
"internalURL": "http://int.manila.example.com:8786/v1.0",
"publicURL": "http://public.manila.example.com:8786/v1.0"}]},
)

View File

@ -0,0 +1,51 @@
#
# 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 openstack_dashboard.test.test_data import utils
def load_test_data(load_onto=None):
from manila_ui.test.test_data import keystone_data as manila_keystone_data
from openstack_dashboard.test.test_data import ceilometer_data
from openstack_dashboard.test.test_data import cinder_data
from openstack_dashboard.test.test_data import exceptions
from openstack_dashboard.test.test_data import glance_data
from openstack_dashboard.test.test_data import heat_data
from openstack_dashboard.test.test_data import keystone_data
from openstack_dashboard.test.test_data import neutron_data
from openstack_dashboard.test.test_data import nova_data
from openstack_dashboard.test.test_data import sahara_data
from openstack_dashboard.test.test_data import swift_data
from openstack_dashboard.test.test_data import trove_data
# The order of these loaders matters, some depend on others.
loaders = (
exceptions.data,
keystone_data.data,
glance_data.data,
nova_data.data,
cinder_data.data,
neutron_data.data,
swift_data.data,
heat_data.data,
ceilometer_data.data,
trove_data.data,
sahara_data.data,
manila_keystone_data.data,
)
if load_onto:
for data_func in loaders:
data_func(load_onto)
return load_onto
else:
return utils.TestData(*loaders)