diff --git a/ddportfolioservice/tests/__init__.py b/ddportfolioservice/tests/__init__.py index e3d153d..4e03c0c 100644 --- a/ddportfolioservice/tests/__init__.py +++ b/ddportfolioservice/tests/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # # DDPortfolio service tests package -# Copyright (c) 2009 Jan Dittberner +# Copyright © 2009, 2010 Jan Dittberner # # This file is part of DDPortfolio service. # @@ -34,29 +34,26 @@ import os import sys from unittest import TestCase -import pkg_resources -import paste.fixture -import paste.script.appinstall from paste.deploy import loadapp -from routes import url_for +from paste.script.appinstall import SetupCommand +from pylons import url +from routes.util import URLGenerator +from webtest import TestApp -__all__ = ['url_for', 'TestController'] +import pylons.test -here_dir = os.path.dirname(os.path.abspath(__file__)) -conf_dir = os.path.dirname(os.path.dirname(here_dir)) +__all__ = ['environ', 'url', 'TestController'] -sys.path.insert(0, conf_dir) -pkg_resources.working_set.add_entry(conf_dir) -pkg_resources.require('Paste') -pkg_resources.require('PasteScript') +# Invoke websetup with the current config file +SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']]) -test_file = os.path.join(conf_dir, 'test.ini') -cmd = paste.script.appinstall.SetupCommand('setup-app') -cmd.run([test_file]) +environ = {} class TestController(TestCase): def __init__(self, *args, **kwargs): - wsgiapp = loadapp('config:test.ini', relative_to=conf_dir) - self.app = paste.fixture.TestApp(wsgiapp) + wsgiapp = pylons.test.pylonsapp + config = wsgiapp.config + self.app = TestApp(wsgiapp) + url._push_object(URLGenerator(config['routes.map'], environ)) TestCase.__init__(self, *args, **kwargs) diff --git a/ddportfolioservice/tests/functional/test_ddportfolio.py b/ddportfolioservice/tests/functional/test_ddportfolio.py index 7693f2f..2a8a6ed 100644 --- a/ddportfolioservice/tests/functional/test_ddportfolio.py +++ b/ddportfolioservice/tests/functional/test_ddportfolio.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # # DDPortfolio service DdportfolioController test -# Copyright (c) 2009 Jan Dittberner +# Copyright © 2009, 2010 Jan Dittberner # # This file is part of DDPortfolio service. # @@ -20,10 +20,11 @@ # License along with this program. If not, see # . # -from ddportfolioservice.tests import * +from ddportfolioservice.tests import TestController, url + class TestDdportfolioController(TestController): def test_index(self): - response = self.app.get(url_for(controller='ddportfolio', action='index')) + response = self.app.get(url(controller='ddportfolio', action='index')) # Test response... diff --git a/ddportfolioservice/tests/functional/test_showformscripts.py b/ddportfolioservice/tests/functional/test_showformscripts.py index 4ce6279..3302743 100644 --- a/ddportfolioservice/tests/functional/test_showformscripts.py +++ b/ddportfolioservice/tests/functional/test_showformscripts.py @@ -1,7 +1,29 @@ -from ddportfolioservice.tests import * +# -*- python -*- +# -*- coding: utf-8 -*- +# +# DDPortfolio service DdportfolioController test +# Copyright © 2009, 2010 Jan Dittberner +# +# This file is part of DDPortfolio service. +# +# DDPortfolio service is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# DDPortfolio service is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# +from ddportfolioservice.tests import TestController, url class TestShowformscriptsController(TestController): def test_index(self): - response = self.app.get(url_for(controller='showformscripts', action='index')) + response = self.app.get(url(controller='showformscripts', action='index')) # Test response... diff --git a/ddportfolioservice/websetup.py b/ddportfolioservice/websetup.py index fcbacd8..2a52f84 100644 --- a/ddportfolioservice/websetup.py +++ b/ddportfolioservice/websetup.py @@ -25,6 +25,7 @@ import logging from paste.deploy import appconfig from pylons import config +import pylons.test from ddportfolioservice.config.environment import load_environment @@ -33,4 +34,6 @@ log = logging.getLogger(__name__) def setup_config(command, filename, section, vars): """Place any commands to setup ddportfolioservice here""" conf = appconfig('config:' + filename) - load_environment(conf.global_conf, conf.local_conf) + + if not pylons.test.pylonsapp: + load_environment(conf.global_conf, conf.local_conf)