Skip to content

Commit

Permalink
add functional test
Browse files Browse the repository at this point in the history
[#29802925]
  • Loading branch information
Reed O'Brien committed May 31, 2012
1 parent f4c735f commit 75c29b1
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions 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

0 comments on commit 75c29b1

Please sign in to comment.