summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-08-18 04:06:35 +0000
committerChris McDonough <chrism@agendaless.com>2008-08-18 04:06:35 +0000
commite35dc1a58a4e91977dc9819c80259f09800a0b58 (patch)
treee90fea96be6f491becd5399f177057f1feeadf68 /repoze/bfg/tests
parent0235914a7c520e20dafcfc251237deddedaf3d80 (diff)
downloadpyramid-e35dc1a58a4e91977dc9819c80259f09800a0b58.tar.gz
pyramid-e35dc1a58a4e91977dc9819c80259f09800a0b58.tar.bz2
pyramid-e35dc1a58a4e91977dc9819c80259f09800a0b58.zip
- Generated application differences: ``make_app`` entry point
renamed to ``app`` in order to have a different name than the bfg function of the same name, to prevent confusion. - Add "options" processing to bfg's ``make_app`` to support runtime options. A new API function named ``get_options`` was added to the registry module. This function is typically used in an application's ``app`` entry point. The Paste config file section for the app can now supply the ``reload_templates`` option, which, if true, will prevent the need to restart the appserver in order for ``z3c.pt`` or XSLT template changes to be detected. - Use only the module name in generated project's "test_suite" (run all tests found in the package). - Default port for generated apps changed from 5432 to 6543 (Postgres default port is 6543).
Diffstat (limited to 'repoze/bfg/tests')
-rw-r--r--repoze/bfg/tests/test_registry.py22
-rw-r--r--repoze/bfg/tests/test_zcml.py31
2 files changed, 22 insertions, 31 deletions
diff --git a/repoze/bfg/tests/test_registry.py b/repoze/bfg/tests/test_registry.py
index 0d051c131..de8481fd8 100644
--- a/repoze/bfg/tests/test_registry.py
+++ b/repoze/bfg/tests/test_registry.py
@@ -23,15 +23,37 @@ class TestMakeRegistry(unittest.TestCase, PlacelessSetup):
old = repoze.bfg.registry.setRegistryManager(dummyregmgr)
registry = makeRegistry('configure.zcml',
fixtureapp,
+ options={'reload_templates':True},
lock=dummylock)
from zope.component.registry import Components
self.failUnless(isinstance(registry, Components))
self.assertEqual(dummylock.acquired, True)
self.assertEqual(dummylock.released, True)
self.assertEqual(dummyregmgr.registry, registry)
+ from zope.component import getUtility
+ from repoze.bfg.interfaces import ISettings
+ settings = getUtility(ISettings)
+ self.assertEqual(settings.reload_templates, True)
finally:
repoze.bfg.registry.setRegistryManager(old)
+class TestGetOptions(unittest.TestCase):
+ def _getFUT(self):
+ from repoze.bfg.registry import get_options
+ return get_options
+
+ def test_it(self):
+ get_options = self._getFUT()
+ self.assertEqual(get_options({}),
+ {'reload_templates':False})
+ self.assertEqual(get_options({'reload_templates':'false'}),
+ {'reload_templates':False})
+ self.assertEqual(get_options({'reload_templates':'t'}),
+ {'reload_templates':True})
+ self.assertEqual(get_options({'reload_templates':'1'}),
+ {'reload_templates':True})
+
+
class TestThreadLocalRegistryManager(unittest.TestCase, PlacelessSetup):
def setUp(self):
PlacelessSetup.setUp(self)
diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py
index 407eaf24e..663022796 100644
--- a/repoze/bfg/tests/test_zcml.py
+++ b/repoze/bfg/tests/test_zcml.py
@@ -114,37 +114,6 @@ class TestViewDirective(unittest.TestCase, PlacelessSetup):
self.assertEqual(regadapt['args'][4], '')
self.assertEqual(regadapt['args'][5], None)
-class TestSettingsDirective(unittest.TestCase, PlacelessSetup):
- def setUp(self):
- PlacelessSetup.setUp(self)
-
- def tearDown(self):
- PlacelessSetup.tearDown(self)
-
- def _getFUT(self):
- from repoze.bfg.zcml import settings
- return settings
-
- def test_defaults(self):
- context = DummyContext()
- settings = self._getFUT()
- settings(context)
- actions = context.actions
- from repoze.bfg.interfaces import ISettings
- from zope.component.zcml import handler
- self.assertEqual(len(actions), 1)
- action = actions[0]
- self.assertEqual(action['discriminator'], ('settings', ISettings))
- self.assertEqual(action['callable'], handler)
- self.assertEqual(len(action['args']), 5)
- self.assertEqual(action['args'][0], 'registerUtility')
- settings = action['args'][1]
- self.assertEqual(settings.reload_templates, False)
- self.failUnless(ISettings.providedBy(settings), settings)
- self.assertEqual(action['args'][2], ISettings)
- self.assertEqual(action['args'][3], '')
- self.assertEqual(action['args'][4], context.info)
-
class TestSampleApp(unittest.TestCase, PlacelessSetup):
def setUp(self):
PlacelessSetup.setUp(self)