diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-12-23 21:11:30 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-12-23 21:11:30 +0000 |
| commit | 7696aab2e51ff7b49ae825219e79fed201f7163f (patch) | |
| tree | d621a0ca09b9400663165ed94cb4f5caa3f63380 /repoze/bfg/tests | |
| parent | 7144388b1fd10fec7a18de7ce1e7fc46c11a9ab6 (diff) | |
| download | pyramid-7696aab2e51ff7b49ae825219e79fed201f7163f.tar.gz pyramid-7696aab2e51ff7b49ae825219e79fed201f7163f.tar.bz2 pyramid-7696aab2e51ff7b49ae825219e79fed201f7163f.zip | |
- Add ``hook_zca`` and ``unhook_zca`` methods to the ``Configurator``
API.
- Add roles to configurator API docs.
Diffstat (limited to 'repoze/bfg/tests')
| -rw-r--r-- | repoze/bfg/tests/test_configuration.py | 31 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_settings.py | 13 |
2 files changed, 31 insertions, 13 deletions
diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py index 3b7c50f60..594f8e8f4 100644 --- a/repoze/bfg/tests/test_configuration.py +++ b/repoze/bfg/tests/test_configuration.py @@ -1908,6 +1908,21 @@ class ConfiguratorTests(unittest.TestCase): config.registry.notify(event2) self.assertEqual(L[-1], event2) + def test_hook_zca(self): + from repoze.bfg.threadlocal import get_current_registry + gsm = DummyGetSiteManager() + config = self._makeOne() + config.hook_zca(getSiteManager=gsm) + self.assertEqual(gsm.hook, get_current_registry) + + def test_unhook_zca(self): + gsm = DummyGetSiteManager() + config = self._makeOne() + config.unhook_zca(getSiteManager=gsm) + self.assertEqual(gsm.unhooked, True) + + + class Test__map_view(unittest.TestCase): def setUp(self): from repoze.bfg.registry import Registry @@ -2744,17 +2759,14 @@ class TestMakeApp(unittest.TestCase): return make_app(*arg, **kw) def test_it(self): - from repoze.bfg.threadlocal import get_current_registry settings = {'a':1} rootfactory = object() - gsm = DummyGetSiteManager() app = self._callFUT(rootfactory, settings=settings, - Configurator=DummyConfigurator, - getSiteManager=gsm) + Configurator=DummyConfigurator) self.assertEqual(app.root_factory, rootfactory) self.assertEqual(app.settings, settings) self.assertEqual(app.zcml_file, 'configure.zcml') - self.assertEqual(gsm.hook, get_current_registry) + self.assertEqual(app.zca_hooked, True) def test_it_options_means_settings(self): settings = {'a':1} @@ -2779,7 +2791,6 @@ class TestMakeApp(unittest.TestCase): Configurator=DummyConfigurator) self.assertEqual(app.zcml_file, '2.zcml') - class DummyRequest: subpath = () def __init__(self): @@ -2857,8 +2868,9 @@ class DummyConfigurator(object): self.package = package self.settings = settings - def begin(self): + def begin(self, request=None): self.begun = True + self.request = request def end(self): self.ended = True @@ -2868,6 +2880,9 @@ class DummyConfigurator(object): def make_wsgi_app(self): return self + + def hook_zca(self): + self.zca_hooked = True class DummyAccept(object): def __init__(self, *matches): @@ -2899,6 +2914,8 @@ class DummyMultiView: class DummyGetSiteManager(object): def sethook(self, hook): self.hook = hook + def reset(self): + self.unhooked = True class DummyThreadLocalManager(object): pushed = None diff --git a/repoze/bfg/tests/test_settings.py b/repoze/bfg/tests/test_settings.py index 258571dda..c86c21de2 100644 --- a/repoze/bfg/tests/test_settings.py +++ b/repoze/bfg/tests/test_settings.py @@ -1,5 +1,4 @@ import unittest -from repoze.bfg.testing import cleanUp class TestSettings(unittest.TestCase): def _getTargetClass(self): @@ -148,10 +147,14 @@ class TestSettings(unittest.TestCase): class TestGetSettings(unittest.TestCase): def setUp(self): - cleanUp() + from repoze.bfg.configuration import Configurator + from repoze.bfg.registry import Registry + registry = Registry('testing') + self.config = Configurator(registry=registry) + self.config.begin() def tearDown(self): - cleanUp() + self.config.end() def _callFUT(self): from repoze.bfg.settings import get_settings @@ -162,9 +165,7 @@ class TestGetSettings(unittest.TestCase): def test_it_withsettings(self): from repoze.bfg.interfaces import ISettings - from repoze.bfg.threadlocal import get_current_registry - reg = get_current_registry() settings = {'a':1} - reg.registerUtility(settings, ISettings) + self.config.registry.registerUtility(settings, ISettings) self.assertEqual(self._callFUT(), settings) |
