summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-06-24 04:04:06 +0000
committerChris McDonough <chrism@agendaless.com>2009-06-24 04:04:06 +0000
commitdc405b2e9bac8e43350442a7824901f5ced8e3d5 (patch)
tree9848b737b83471905ad95df6e34c12f568398c53 /repoze/bfg/tests
parentaffef3124f49441989522a5c87589d37a9b8585a (diff)
downloadpyramid-dc405b2e9bac8e43350442a7824901f5ced8e3d5.tar.gz
pyramid-dc405b2e9bac8e43350442a7824901f5ced8e3d5.tar.bz2
pyramid-dc405b2e9bac8e43350442a7824901f5ced8e3d5.zip
- Added the ``repoze.bfg.url.route_url`` API. This is meant to
"front" for the Routes ``url_for`` API. See the URL Dispatch narrative chapter and the "repoze.bfg.url" module API documentation for more information.
Diffstat (limited to 'repoze/bfg/tests')
-rw-r--r--repoze/bfg/tests/test_url.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_url.py b/repoze/bfg/tests/test_url.py
index 64cf52383..e42089173 100644
--- a/repoze/bfg/tests/test_url.py
+++ b/repoze/bfg/tests/test_url.py
@@ -156,6 +156,50 @@ class UrlEncodeTests(unittest.TestCase):
def test_dict(self):
result = self._callFUT({'a':1})
self.assertEqual(result, 'a=1')
+
+class TestRouteUrl(unittest.TestCase):
+ def _callFUT(self, *arg, **kw):
+ from repoze.bfg.url import route_url
+ return route_url(*arg, **kw)
+
+ def test_it(self):
+ from routes import Mapper
+ mapper = Mapper(controller_scan=None, directory=None,
+ explicit=True, always_scan=False)
+ args = {'a':'1', 'b':'2', 'c':'3'}
+ mapper.connect('flub', ':a/:b/:c')
+ mapper.create_regs([])
+ environ = {'SERVER_NAME':'example.com', 'wsgi.url_scheme':'http',
+ 'SERVER_PORT':'80', 'wsgiorg.routing_args':((), args)}
+ mapper.environ = environ
+ from routes import request_config
+ config = request_config()
+ config.environ = environ
+ config.mapper = mapper
+ config.redirect = None
+ request = DummyRequest()
+ request.environ = environ
+ result = self._callFUT('flub', a=1, b=2, c=3)
+ self.assertEqual(result, 'http://example.com/1/2/3')
+
+ def test_it_generation_error(self):
+ from routes import Mapper
+ mapper = Mapper(controller_scan=None, directory=None,
+ explicit=True, always_scan=False)
+ args = {'a':'1', 'b':'2', 'c':'3'}
+ mapper.connect('flub', ':a/:b/:c')
+ mapper.create_regs([])
+ environ = {'SERVER_NAME':'example.com', 'wsgi.url_scheme':'http',
+ 'SERVER_PORT':'80', 'wsgiorg.routing_args':((), args)}
+ mapper.environ = environ
+ from routes import request_config
+ config = request_config()
+ config.environ = environ
+ config.mapper = mapper
+ config.redirect = None
+ request = DummyRequest()
+ request.environ = environ
+ self.assertRaises(ValueError, self._callFUT, 'flub', a=1)
class DummyContext(object):
def __init__(self, next=None):