diff --git a/development.ini b/development.ini index ef4cebb..3aae86b 100644 --- a/development.ini +++ b/development.ini @@ -8,6 +8,7 @@ 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 @@ -15,6 +16,15 @@ 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 diff --git a/riotoustools/__init__.py b/riotoustools/__init__.py index d2ef9f0..139147d 100644 --- a/riotoustools/__init__.py +++ b/riotoustools/__init__.py @@ -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 @@ -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, @@ -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) diff --git a/tests/functional/test_dayzero_views.py b/tests/functional/test_dayzero_views.py deleted file mode 100644 index d3bd7a1..0000000 --- a/tests/functional/test_dayzero_views.py +++ /dev/null @@ -1,9 +0,0 @@ -from tests import * - -from riotoustools import main - -class DayZeroRequestTest(TestCase): - def setUp(self): - self.app = TestApp(main()) - print self.app - assert True \ No newline at end of file diff --git a/tests/functional/test_default_views.py b/tests/functional/test_default_views.py new file mode 100644 index 0000000..eff236c --- /dev/null +++ b/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 \ No newline at end of file diff --git a/tests/unit/test_dayzero_models.py b/tests/unit/test_dayzero_models.py new file mode 100644 index 0000000..21beb4c --- /dev/null +++ b/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)) \ No newline at end of file diff --git a/tests/unit/test_lifecal_models.py b/tests/unit/test_lifecal_models.py new file mode 100644 index 0000000..8d421b4 --- /dev/null +++ b/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)) + \ No newline at end of file