summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-05-01 09:06:54 +0000
committerChris McDonough <chrism@agendaless.com>2009-05-01 09:06:54 +0000
commit8e037fda9af695b608240d8fed085c403f657011 (patch)
tree9603414fe4bcb2ea8b6a93dd3b5856ae5c5d2728 /repoze/bfg/tests
parent25c8f66346eab8ec9455e8dc734bf2b407e2e423 (diff)
downloadpyramid-8e037fda9af695b608240d8fed085c403f657011.tar.gz
pyramid-8e037fda9af695b608240d8fed085c403f657011.tar.bz2
pyramid-8e037fda9af695b608240d8fed085c403f657011.zip
- In previous releases, the ``repoze.bfg.url.model_url``,
``repoze.bfg.traversal.model_path`` and ``repoze.bfg.traversal.model_path_tuple`` functions always ignored the ``__name__`` argument of the root object in a model graph ( effectively replacing it with a leading ``/`` in the returned value) when a path or URL was generated. The code required to perform this operation was not efficient. As of this release, the root object in a model graph *must* have a ``__name__`` attribute that is either ``None`` or the empty string (``''``) for URLs and paths to be generated properly from these APIs. If your root model object has a ``__name__`` argument that is not one of these values, you will need to change your code for URLs and paths to be generated properly. If your model graph has a root node with a string ``__name__`` that is not null, the value of ``__name__`` will be prepended to every path and URL generated.
Diffstat (limited to 'repoze/bfg/tests')
-rw-r--r--repoze/bfg/tests/test_traversal.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/repoze/bfg/tests/test_traversal.py b/repoze/bfg/tests/test_traversal.py
index f361d0a79..867dae318 100644
--- a/repoze/bfg/tests/test_traversal.py
+++ b/repoze/bfg/tests/test_traversal.py
@@ -384,7 +384,31 @@ class ModelPathTests(unittest.TestCase):
root.__name__ = None
result = self._callFUT(root)
self.assertEqual(result, '/')
-
+
+ def test_root_default_emptystring(self):
+ root = DummyContext()
+ root.__parent__ = None
+ root.__name__ = ''
+ result = self._callFUT(root)
+ self.assertEqual(result, '/')
+
+ def test_root_object_nonnull_name_direct(self):
+ root = DummyContext()
+ root.__parent__ = None
+ root.__name__ = 'flubadub'
+ result = self._callFUT(root)
+ self.assertEqual(result, 'flubadub') # insane case
+
+ def test_root_object_nonnull_name_indirect(self):
+ root = DummyContext()
+ root.__parent__ = None
+ root.__name__ = 'flubadub'
+ other = DummyContext()
+ other.__parent__ = root
+ other.__name__ = 'barker'
+ result = self._callFUT(other)
+ self.assertEqual(result, 'flubadub/barker') # insane case
+
def test_nonroot_default(self):
root = DummyContext()
root.__parent__ = None