Skip to content

Commit

Permalink
Fix tests to work with Zope master which expects requests to have an …
Browse files Browse the repository at this point in the history
…ensure_publishable method.
  • Loading branch information
mauritsvanrees authored and jensens committed Apr 24, 2024
1 parent 7e27bb5 commit 5cfa198
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 2 additions & 0 deletions news/1202.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix tests to work with Zope master which expects requests to have an `ensure_publishable` method.
[maurits]
34 changes: 22 additions & 12 deletions plone/dexterity/tests/test_webdav.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class DAVTestRequest(TestRequest):
def _createResponse(self):
return HTTPResponse()

def ensure_publishable(self, obj, for_call=False):
# Needed for Zope > 5.9.
return


class TestWebZope2DAVAPI(MockTestCase):
def test_get_size_no_adapter(self):
Expand Down Expand Up @@ -1295,18 +1299,21 @@ def lock_request(self):
return lock_request

def test_get_subfolder(self):
traversal = DexterityPublishTraverse(self.folder, None)
traversed = traversal.publishTraverse(self.get_request, "subfolder")
request = self.get_request
traversal = DexterityPublishTraverse(self.folder, request)
traversed = traversal.publishTraverse(request, "subfolder")
self.assertEqual(traversed, self.subfolder)

def test_lock_subfolder(self):
traversal = DexterityPublishTraverse(self.folder, None)
traversed = traversal.publishTraverse(self.lock_request, "subfolder")
request = self.lock_request
traversal = DexterityPublishTraverse(self.folder, request)
traversed = traversal.publishTraverse(request, "subfolder")
self.assertEqual(traversed, self.subfolder)

def test_get_acquired(self):
traversal = DexterityPublishTraverse(self.subfolder, None)
traversed = traversal.publishTraverse(self.get_request, "folder")
request = self.get_request
traversal = DexterityPublishTraverse(self.subfolder, request)
traversed = traversal.publishTraverse(request, "folder")
self.assertEqual(traversed, self.folder)

def test_lock_acquired(self):
Expand All @@ -1315,22 +1322,25 @@ def test_lock_acquired(self):
"""
from webdav.NullResource import NullResource

traversal = DexterityPublishTraverse(self.subfolder, None)
traversed = traversal.publishTraverse(self.lock_request, "folder")
request = self.lock_request
traversal = DexterityPublishTraverse(self.subfolder, request)
traversed = traversal.publishTraverse(request, "folder")
self.assertIsInstance(traversed, NullResource)

def test_get_vhm(self):
"""Ensure we can handle virtual hosting with regular requests"""
from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster

traversal = DexterityPublishTraverse(self.folder, None)
traversed = traversal.publishTraverse(self.get_request, "virtual_hosting")
request = self.get_request
traversal = DexterityPublishTraverse(self.folder, request)
traversed = traversal.publishTraverse(request, "virtual_hosting")
self.assertIsInstance(traversed, VirtualHostMonster)

def test_lock_vhm(self):
"""Ensure we can handle virtual hosting with dav requests"""
from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster

traversal = DexterityPublishTraverse(self.folder, None)
traversed = traversal.publishTraverse(self.lock_request, "virtual_hosting")
request = self.lock_request
traversal = DexterityPublishTraverse(self.folder, request)
traversed = traversal.publishTraverse(request, "virtual_hosting")
self.assertIsInstance(traversed, VirtualHostMonster)

0 comments on commit 5cfa198

Please sign in to comment.