summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests/test_traversal.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-12-14 04:00:07 +0000
committerChris McDonough <chrism@agendaless.com>2008-12-14 04:00:07 +0000
commitc8a91c6fa1eb4daa6be6dc7098518345bc6aa9bb (patch)
tree00c9b550c33efc38ae97a0a41d2f9d06423fa735 /repoze/bfg/tests/test_traversal.py
parent2a5cc44832a757f0ace22eccbec94fac893de600 (diff)
downloadpyramid-c8a91c6fa1eb4daa6be6dc7098518345bc6aa9bb.tar.gz
pyramid-c8a91c6fa1eb4daa6be6dc7098518345bc6aa9bb.tar.bz2
pyramid-c8a91c6fa1eb4daa6be6dc7098518345bc6aa9bb.zip
Backwards Incompatibilities
- URL-quote "extra" element names passed in as ``**elements`` to the ``traversal.model_url`` API. If any of these names is a Unicode string, encode it to UTF-8 before URL-quoting. This is a slight backwards incompatibility that will impact you if you were already UTF-8 encoding or URL-quoting the values you passed in as ``elements`` to this API. Bugfixes - UTF-8 encode each segment in the model path used to generate a URL before url-quoting it within the ``traversal.model_url`` API. This is a bugfix, as Unicode cannot always be successfully URL-quoted.
Diffstat (limited to 'repoze/bfg/tests/test_traversal.py')
-rw-r--r--repoze/bfg/tests/test_traversal.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_traversal.py b/repoze/bfg/tests/test_traversal.py
index 2c02d7d63..32be1ebbb 100644
--- a/repoze/bfg/tests/test_traversal.py
+++ b/repoze/bfg/tests/test_traversal.py
@@ -256,6 +256,45 @@ class ModelURLTests(unittest.TestCase):
result = self._callFUT(other, request)
self.assertEqual(result, 'http://example.com:5432/nonroot%20object/')
+ def test_unicode_mixed_with_bytes_in_model_names(self):
+ root = DummyContext()
+ root.__parent__ = None
+ root.__name__ = None
+ one = DummyContext()
+ one.__parent__ = root
+ one.__name__ = unicode('La Pe\xc3\xb1a', 'utf-8')
+ two = DummyContext()
+ two.__parent__ = one
+ two.__name__ = 'La Pe\xc3\xb1a'
+ request = DummyRequest()
+ request.application_url = 'http://example.com:5432'
+ result = self._callFUT(two, request)
+ self.assertEqual(result,
+ 'http://example.com:5432/La%20Pe%C3%B1a/La%20Pe%C3%B1a/')
+
+ def test_unicode_in_element_names(self):
+ uc = unicode('La Pe\xc3\xb1a', 'utf-8')
+ root = DummyContext()
+ root.__parent__ = None
+ root.__name__ = None
+ one = DummyContext()
+ one.__parent__ = root
+ one.__name__ = uc
+ request = DummyRequest()
+ request.application_url = 'http://example.com:5432'
+ result = self._callFUT(one, request, uc)
+ self.assertEqual(result,
+ 'http://example.com:5432/La%20Pe%C3%B1a/La%20Pe%C3%B1a')
+
+ def test_element_names_url_quoted(self):
+ root = DummyContext()
+ root.__parent__ = None
+ root.__name__ = None
+ request = DummyRequest()
+ request.application_url = 'http://example.com:5432'
+ result = self._callFUT(root, request, 'a b c')
+ self.assertEqual(result, 'http://example.com:5432/a%20b%20c')
+
class FindRootTests(unittest.TestCase):
def _callFUT(self, context):
from repoze.bfg.traversal import find_root