From ad406f50aea5db8b399e7f9d502c06b6253f8a21 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 31 Oct 2009 16:21:51 +0000 Subject: Fix default root factory in the face of changes to root factory construction arg. --- repoze/bfg/tests/test_configuration.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'repoze/bfg/tests/test_configuration.py') diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py index e15bba5a9..669ee2ecf 100644 --- a/repoze/bfg/tests/test_configuration.py +++ b/repoze/bfg/tests/test_configuration.py @@ -217,6 +217,30 @@ class MakeRegistryTests(unittest.TestCase): self.assertEqual(dummylock.acquired, True) self.assertEqual(dummylock.released, True) +class TestDefaultRootFactory(unittest.TestCase): + def _getTargetClass(self): + from repoze.bfg.configuration import DefaultRootFactory + return DefaultRootFactory + + def _makeOne(self, environ): + return self._getTargetClass()(environ) + + def test_no_matchdict(self): + environ = {} + root = self._makeOne(environ) + self.assertEqual(root.__parent__, None) + self.assertEqual(root.__name__, None) + + def test_matchdict(self): + request = DummyRequest() + request.matchdict = {'a':1, 'b':2} + root = self._makeOne(request) + self.assertEqual(root.a, 1) + self.assertEqual(root.b, 2) + +class DummyRequest: + pass + class DummyRegistryManager: def push(self, registry): from repoze.bfg.threadlocal import manager -- cgit v1.2.3