Skip to content

Commit

Permalink
test that we can actually create the app
Browse files Browse the repository at this point in the history
  • Loading branch information
santagada committed Jul 18, 2013
1 parent 691c6dd commit fbede98
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
5 changes: 5 additions & 0 deletions development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ pyramid.includes =

sqlalchemy.url = sqlite:///%(here)s/timtec.sqlite

horus.user_class = timtec.models.User
horus.activation_class = timtec.models.Activation
horus.login_redirect = login
horus.logout_redirect = logout

# By default, the toolbar only appears for clients from IP addresses
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
Expand Down
15 changes: 12 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import transaction

from pyramid import testing

from pkg_resources import resource_filename
from pyramid import (
testing,
router,
)
from timtec.models import DBSession

config = None
Expand Down Expand Up @@ -34,3 +36,10 @@ def test_it():
info = my_view(request)
assert info['one'].username == 'one'
assert info['project'] == 'timtec'

def test_app_creation():
from paste.deploy.loadwsgi import appconfig
from timtec import main
settings = appconfig('config:' + resource_filename(__name__, '../development.ini'))
app = main(config, **settings)
assert isinstance(app, router.Router)
10 changes: 7 additions & 3 deletions timtec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
from hem.interfaces import IDBSession

from .models import (
DBSession,
Expand All @@ -14,10 +15,13 @@ def main(global_config, **settings):
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.include('horus')
config.include('pyramid_mailer')
config.registry.registerUtility(DBSession, IDBSession)
# config.scan_horus(models)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.scan()
config.include('horus')
config.include('pyramid_mailer')
config.scan_horus(models)
return config.make_wsgi_app()
7 changes: 3 additions & 4 deletions timtec/scripts/initializedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from ..models import (
DBSession,
MyModel,
Base,
)

Expand All @@ -32,6 +31,6 @@ def main(argv=sys.argv):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
model = MyModel(name='one', value=1)
DBSession.add(model)
# with transaction.manager:
# model = MyModel(name='one', value=1)
# DBSession.add(model)

0 comments on commit fbede98

Please sign in to comment.