Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests to work with Zope master #198

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[meta]
template = "default"
commit-id = "6e36bcc4"

[pyproject]
codespell_ignores = "succeded"
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]
37 changes: 22 additions & 15 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 @@ -601,9 +605,6 @@ def content_type(self):
)
body = body.strip()
result = response.getBody().strip()
# TODO: remove next line when Zope 5.8.1 is released and used in coredev.
# Then also remove codespell settings from .meta.toml and pyproject.toml.
result = result.replace(b"succeded", b"succeeded")
self.assertEqual(body, result)

def test_LOCK(self):
Expand Down Expand Up @@ -1295,18 +1296,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 +1319,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)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ target-version = ["py38"]
##

[tool.codespell]
ignore-words-list = "discreet,succeded"
ignore-words-list = "discreet"
skip = "*.po,"
##
# Add extra configuration options in .meta.toml:
Expand Down