From 75c29b10dbb246dff016723e25c6d5862c36907d Mon Sep 17 00:00:00 2001 From: Reed O'Brien Date: Wed, 30 May 2012 22:41:54 -0400 Subject: [PATCH] add functional test [#29802925] --- kotti_splashpage/tests.py | 49 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/kotti_splashpage/tests.py b/kotti_splashpage/tests.py index 19adaa5..80feb1f 100644 --- a/kotti_splashpage/tests.py +++ b/kotti_splashpage/tests.py @@ -1,7 +1,50 @@ from kotti.testing import FunctionalTestBase +from kotti.testing import ( + tearDown, + testing_db_url, + ) + +BASE_URL = 'http://localhost:5000' + + +def setUpFunctional(global_config=None, **settings): + from kotti import main + import wsgi_intercept.zope_testbrowser + from webtest import TestApp + + tearDown() + + _settings = { + 'sqlalchemy.url': testing_db_url(), + 'kotti.secret': 'secret', + 'kotti.site_title': 'Test Splash Page', # for mailing + 'kotti.populators': + 'kotti.testing._populator\nkotti_splashpage.populate', + 'mail.default_sender': 'kotti@localhost', + 'kotti.includes': 'kotti_splashpage' + } + _settings.update(settings) + + host, port = BASE_URL.split(':')[-2:] + app = main({}, **_settings) + wsgi_intercept.add_wsgi_intercept(host[2:], int(port), lambda: app) + Browser = wsgi_intercept.zope_testbrowser.WSGI_Browser + + return dict( + Browser=Browser, + browser=Browser(), + test_app=TestApp(app), + ) + + +class TestSplashFunctional(FunctionalTestBase): + BASE_URL = BASE_URL + + def setUp(self, **kwargs): + self.__dict__.update(setUpFunctional(**kwargs)) -class TestLogin(FunctionalTestBase): def test_it(self): - assert self.browser.status == '200 OK' - assert 'SPLASH PAGE' in self + result = self.test_app.get('/') + assert result.status == '200 OK' + assert 'SPLASH PAGE' in result.body