Skip to content

Commit

Permalink
More test coverage and cache regions!
Browse files Browse the repository at this point in the history
  • Loading branch information
wwitzel3 committed Feb 3, 2011
1 parent 2a7df71 commit a47e61a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 12 deletions.
10 changes: 10 additions & 0 deletions development.ini
Expand Up @@ -8,13 +8,23 @@ debug_templates = true
default_locale_name = en
sqlalchemy.url = sqlite:///%(here)s/riotoustools.db
mako.directories = %(here)s/riotoustools/templates

session.type = file
session.data_dir = %(here)s/data/sessions/data
session.lock_dir = %(here)s/data/sessions/lock
session.key = riotouskey
session.secret = riotoussecret
session.cookie_on_exception = true

cache.data_dir = %(here)s/data/cache/data
cache.lock_dir = %(here)s/data/cache/lock
cache.region = short_term, long_term
cache.short_term.type = ext:memcached
cache.short_term.url = 127.0.0.1:11211
cache.short_term.expire = 3600
cache.short_term.type = file
cache.long_term.expire = 3600

[pipeline:main]
pipeline =
egg:WebError#evalerror
Expand Down
6 changes: 3 additions & 3 deletions riotoustools/__init__.py
Expand Up @@ -4,7 +4,7 @@
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid_beaker import session_factory_from_settings

from pyramid_beaker import set_cache_regions_from_settings
from sqlalchemy import engine_from_config

from riotoustools.models.root import root_factory_maker
Expand All @@ -22,8 +22,9 @@ def main(global_config, **settings):
callback=groupfinder)
authz_policy = ACLAuthorizationPolicy()

# gimmie that Beaker session YO!
# gimmie that Beaker session and region caching YO!
session_factory = session_factory_from_settings(settings)
set_cache_regions_from_settings(settings)

# now make my app respect all of the stuff I just did
config = Configurator(settings=settings,
Expand All @@ -35,7 +36,6 @@ def main(global_config, **settings):

# setup the databasage
engine = engine_from_config(settings, 'sqlalchemy.')
print engine
config.scan('riotoustools.models')
initialize_sql(engine)

Expand Down
9 changes: 0 additions & 9 deletions tests/functional/test_dayzero_views.py

This file was deleted.

11 changes: 11 additions & 0 deletions tests/functional/test_default_views.py
@@ -0,0 +1,11 @@
from tests import *

from riotoustools import main

class DayZeroDefaultViewTest(TestCase):
def setUp(self):
self.app = TestApp(main({}, **settings))

def test_default_root(self):
response = self.app.get('/', status=200)
print response.body
27 changes: 27 additions & 0 deletions tests/unit/test_dayzero_models.py
@@ -0,0 +1,27 @@
from tests import *

from riotoustools.models.user import User
from riotoustools.models.dayzero import DayZeroList
from riotoustools.models.dayzero import DayZeroItem

class DayZeroModelTest(TestCase):
def setUp(self):
self.user = User('name', 'email', 'password')

self.dzl = DayZeroList('name')
self.dzl.id = 1
self.dzl.user = self.user
self.dzl.owner_id = self.user.id

def test_dayzero_acl(self):
self.assertEquals(self.dzl.__acl__[0][1], 'owner:{0}'.format(self.user.id))

def test_dayzero_str(self):
self.assertEquals(str(self.dzl), 'DayZeroList(id={0}, owner_id={1})'.format(self.dzl.id, self.dzl.user.id))

def test_dayzero_repr(self):
self.assertEquals(repr(self.dzl), 'DayZeroList(id={0}, owner_id={1})'.format(self.dzl.id, self.dzl.user.id))

def test_dayzero_item_acl(self):
self.dzl.items.append(DayZeroItem('test'))
self.assertEquals(self.dzl.items[0].__acl__[0][1], 'owner:{0}'.format(self.user.id))
17 changes: 17 additions & 0 deletions tests/unit/test_lifecal_models.py
@@ -0,0 +1,17 @@
from tests import *

from riotoustools.models.user import User
from riotoustools.models.lifecal import LifeCal

class DayZeroModelTest(TestCase):
def setUp(self):
self.user = User('name', 'email', 'password')

self.lifecal = LifeCal()
self.lifecal.id = 1
self.lifecal.user = self.user
self.lifecal.owner_id = self.user.id

def test_lifecal_acl(self):
self.assertEquals(self.lifecal.__acl__[0][1], 'owner:{0}'.format(self.user.id))

0 comments on commit a47e61a

Please sign in to comment.