summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/api/paster.rst9
-rw-r--r--pyramid/tests/test_paster.py41
2 files changed, 47 insertions, 3 deletions
diff --git a/docs/api/paster.rst b/docs/api/paster.rst
index 09e768fae..2a32e07e9 100644
--- a/docs/api/paster.rst
+++ b/docs/api/paster.rst
@@ -5,6 +5,13 @@
.. automodule:: pyramid.paster
- .. autofunction:: get_app
+ .. function:: get_app(config_uri, name=None)
+
+ Return the WSGI application named ``name`` in the PasteDeploy
+ config file specified by ``config_uri``.
+
+ If the ``name`` is None, this will attempt to parse the name from
+ the ``config_uri`` string expecting the format ``inifile#name``.
+ If no name is found, the name will default to "main".
.. autofunction:: bootstrap
diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py
index e7a3b7507..df55afcb8 100644
--- a/pyramid/tests/test_paster.py
+++ b/pyramid/tests/test_paster.py
@@ -928,8 +928,45 @@ class TestGetApp(unittest.TestCase):
self.assertEqual(loadapp.section_name, 'yourapp')
self.assertEqual(loadapp.relative_to, os.getcwd())
self.assertEqual(result, app)
-
-
+
+class TestBootstrap(unittest.TestCase):
+ def _callFUT(self, config_uri, request=None):
+ from pyramid.paster import bootstrap
+ return bootstrap(config_uri, request)
+
+ def setUp(self):
+ import pyramid.paster
+ self.original_get_app = pyramid.paster.get_app
+ self.original_getroot2 = pyramid.paster.get_root2
+ self.app = app = DummyApp()
+ self.root = root = Dummy()
+
+ class DummyGetApp(object):
+ def __call__(self, *a, **kw):
+ self.a = a
+ self.kw = kw
+ return app
+ self.get_app = pyramid.paster.get_app = DummyGetApp()
+
+ class DummyGetRoot2(object):
+ def __call__(self, *a, **kw):
+ self.a = a
+ self.kw = kw
+ return (root, lambda: None)
+ self.getroot = pyramid.paster.get_root2 = DummyGetRoot2()
+
+ def tearDown(self):
+ import pyramid.paster
+ pyramid.paster.get_app = self.original_get_app
+ pyramid.paster.get_root2 = self.original_getroot2
+
+ def test_it_request_with_registry(self):
+ request = DummyRequest({})
+ request.registry = dummy_registry
+ result = self._callFUT('/foo/bar/myapp.ini', request)
+ self.assertEqual(result['app'], self.app)
+ self.assertEqual(result['root'], self.root)
+ self.assert_('closer' in result)
class Dummy:
pass