From 0b24a43ed4ad31add861e5f978cf662c75127624 Mon Sep 17 00:00:00 2001 From: Hua Wang Date: Sat, 18 Jul 2015 03:46:01 +0800 Subject: [PATCH] Remove duplicate app loading Testing app has be and should be loaded in the FunctionalTest class. So we should remove the duplicate app loading in the TestCase class. The config.py file is not used if we remove the duplicate app loading.So let's remove it. If we remove the duplicate app loading, TestContainerController should be modified. The base class of it should be FunctionalTest. By the way, rename path_get to get_path. Change-Id: I93d69d9392ecb8ae0303efe14574a6ebe9a82b3c Closes-Bug: #1478194 --- magnum/tests/base.py | 7 +--- magnum/tests/config.py | 40 ------------------- magnum/tests/unit/api/base.py | 2 +- .../unit/api/controllers/v1/test_container.py | 4 +- 4 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 magnum/tests/config.py diff --git a/magnum/tests/base.py b/magnum/tests/base.py index 748714699c..3f7bc57f34 100644 --- a/magnum/tests/base.py +++ b/magnum/tests/base.py @@ -23,7 +23,6 @@ from oslo_config import cfg from oslo_log import log from oslotest import base import pecan -from pecan import testing import testscenarios from magnum.common import context as magnum_context @@ -50,10 +49,6 @@ class TestCase(base.BaseTestCase): def setUp(self): super(TestCase, self).setUp() - self.app = testing.load_test_app(os.path.join( - os.path.dirname(__file__), - 'config.py' - )) token_info = { 'token': { 'project': { @@ -108,7 +103,7 @@ class TestCase(base.BaseTestCase): for k, v in kw.items(): CONF.set_override(k, v, group) - def path_get(self, project_file=None): + def get_path(self, project_file=None): """Get the absolute path to a file. Used for testing the API. :param project_file: File whose path to return. Default: None. diff --git a/magnum/tests/config.py b/magnum/tests/config.py deleted file mode 100644 index 7b4c63f04c..0000000000 --- a/magnum/tests/config.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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 magnum.api import hooks - -# Server Specific Configurations -server = { - 'port': '8080', - 'host': '0.0.0.0' -} - -# Pecan Application Configurations -app = { - 'root': 'magnum.api.controllers.root.RootController', - 'modules': ['magnum.api'], - 'debug': True, - 'hooks': [ - hooks.ContextHook(), - hooks.RPCHook() - ], - 'acl_public_routes': [ - '/' - ], -} - -# Custom Configurations must be in Python dictionary format:: -# -# foo = {'bar':'baz'} -# -# All configurations are accessible at:: -# pecan.conf diff --git a/magnum/tests/unit/api/base.py b/magnum/tests/unit/api/base.py index d14fd590cc..2e2a514eb6 100644 --- a/magnum/tests/unit/api/base.py +++ b/magnum/tests/unit/api/base.py @@ -57,7 +57,7 @@ class FunctionalTest(base.DbTestCase): def _make_app(self, enable_acl=False): # Determine where we are so we can set up paths in the config - root_dir = self.path_get() + root_dir = self.get_path() self.config = { 'app': { diff --git a/magnum/tests/unit/api/controllers/v1/test_container.py b/magnum/tests/unit/api/controllers/v1/test_container.py index 0d5c930fef..e60642f005 100644 --- a/magnum/tests/unit/api/controllers/v1/test_container.py +++ b/magnum/tests/unit/api/controllers/v1/test_container.py @@ -11,7 +11,7 @@ # limitations under the License. from magnum import objects -from magnum.tests.unit.db import base as db_base +from magnum.tests.unit.api import base as api_base from magnum.tests.unit.db import utils import mock @@ -19,7 +19,7 @@ from mock import patch from webtest.app import AppError -class TestContainerController(db_base.DbTestCase): +class TestContainerController(api_base.FunctionalTest): def setUp(self): super(TestContainerController, self).setUp() p = patch('magnum.objects.Bay.get_by_uuid')