[Zope3-checkins] SVN: Zope3/branches/3.3/src/zope/app/tree/ Merge from trunk:

Philipp von Weitershausen philikon at philikon.de
Sun Jul 2 09:02:28 EDT 2006


Log message for revision 68951:
  Merge from trunk:
   Log message for revision 68950:
    Fix missing imports and write tests for the codepaths that had those problems.
  

Changed:
  U   Zope3/branches/3.3/src/zope/app/tree/browser/cookie.py
  U   Zope3/branches/3.3/src/zope/app/tree/browser/tests.py
  U   Zope3/branches/3.3/src/zope/app/tree/tests/basetest.py

-=-
Modified: Zope3/branches/3.3/src/zope/app/tree/browser/cookie.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/tree/browser/cookie.py	2006-07-02 13:00:23 UTC (rev 68950)
+++ Zope3/branches/3.3/src/zope/app/tree/browser/cookie.py	2006-07-02 13:02:27 UTC (rev 68951)
@@ -55,7 +55,7 @@
         node.
         """
         parent = self.context
-        for parent in zapi.getParents(self.context):
+        for parent in zope.traversing.api.getParents(self.context):
             if ISite.providedBy(parent):
                 break
         return self.folderTree(parent)
@@ -64,7 +64,7 @@
         """Cookie tree with only folders and the root container as
         root node.
         """
-        root = zapi.getRoot(self.context)
+        root = zope.traversing.api.getRoot(self.context)
         return self.folderTree(root)
 
     def virtualHostTree(self):
@@ -75,5 +75,5 @@
         if vh:
             return self.folderTree(vh)
         else:
-            root = zapi.getRoot(self.context)
+            root = zope.traversing.api.getRoot(self.context)
             return self.folderTree(root)

Modified: Zope3/branches/3.3/src/zope/app/tree/browser/tests.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/tree/browser/tests.py	2006-07-02 13:00:23 UTC (rev 68950)
+++ Zope3/branches/3.3/src/zope/app/tree/browser/tests.py	2006-07-02 13:02:27 UTC (rev 68951)
@@ -17,9 +17,14 @@
 """
 
 import unittest
+import zope.component
+from zope.component import getMultiAdapter
 from zope.publisher.browser import TestRequest
-from zope.app import zapi
+from zope.interface import alsoProvides
+from zope.traversing.interfaces import IContainmentRoot
+from zope.location.traversing import LocationPhysicallyLocatable
 from zope.app.testing import ztapi
+from zope.app.component.interfaces import ISite
 
 from zope.app.tree.utils import TreeStateEncoder
 from zope.app.tree.browser import StatefulTreeView
@@ -44,6 +49,7 @@
     def setUp(self):
         super(CookieTreeViewTest, self).setUp()
         ztapi.browserView(None, 'cookie_tree', CookieTreeView)
+        zope.component.provideAdapter(LocationPhysicallyLocatable)
 
     def makeRequestWithVar(self):
         varname = CookieTreeView.request_variable 
@@ -55,7 +61,7 @@
 
     def test_cookie_tree_pre_expanded(self):
         request = self.makeRequestWithVar()
-        view = zapi.getMultiAdapter((self.root_obj, request),
+        view = getMultiAdapter((self.root_obj, request),
                                     name='cookie_tree')
         cookie_tree = view.cookieTree()
         self.assert_(self.root_node.expanded)
@@ -64,11 +70,29 @@
 
     def test_cookie_tree_sets_cookie(self):
         request = self.makeRequestWithVar()
-        view = zapi.getMultiAdapter((self.root_obj, request),
-                                    name='cookie_tree')
+        view = getMultiAdapter((self.root_obj, request),
+                               name='cookie_tree')
         cookie_tree = view.cookieTree()
         self.failIf(request.response.getCookie(view.request_variable) is None)
 
+    def test_cookie_tree_site_tree(self):
+        request = self.makeRequestWithVar()
+        alsoProvides(self.items['a'], IContainmentRoot)
+        alsoProvides(self.items['c'], ISite)
+        view = getMultiAdapter((self.items['f'], request),
+                               name='cookie_tree')
+        cookie_tree = view.siteTree()
+        self.assert_(cookie_tree.context is self.items['c'])
+
+    def test_cookie_tree_root_tree(self):
+        request = self.makeRequestWithVar()
+        alsoProvides(self.items['c'], IContainmentRoot)
+        view = getMultiAdapter((self.items['f'], request),
+                               name='cookie_tree')
+        cookie_tree = view.rootTree()
+        self.assert_(cookie_tree.context is self.items['c'])
+        
+
 def test_suite():
     suite = unittest.makeSuite(StatefulTreeViewTest)
     suite.addTest(unittest.makeSuite(CookieTreeViewTest))

Modified: Zope3/branches/3.3/src/zope/app/tree/tests/basetest.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/tree/tests/basetest.py	2006-07-02 13:00:23 UTC (rev 68950)
+++ Zope3/branches/3.3/src/zope/app/tree/tests/basetest.py	2006-07-02 13:02:27 UTC (rev 68951)
@@ -17,6 +17,7 @@
 """
 import unittest
 from zope.interface import implements, Interface, Attribute
+from zope.location import Location
 from zope.app.testing.placelesssetup import PlacelessSetup
 from zope.app.testing import ztapi
 
@@ -31,12 +32,14 @@
     id = Attribute("id")
     children = Attribute("children")
 
-class Item(object):
+class Item(Location):
     implements(IItem)
 
     def __init__(self, id, children=[]):
         self.id = id
         self.children = children
+        for child in children:
+            child.__parent__ = self
 
 class ItemUniqueId(object):
     """Simplistic adapter from IItem to IUniqueId



More information about the Zope3-Checkins mailing list