Skip to content

Commit

Permalink
Merge pull request #57 from plone/pa-discussion-core-addon-2
Browse files Browse the repository at this point in the history
Prepare for pa.discussion core addon
  • Loading branch information
jensens authored May 31, 2024
2 parents e2eed20 + 72170fa commit ee216d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Products/CMFDiffTool/tests/testChangeSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FUNCTIONAL_TESTING
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.base.utils import get_installer
from plone.base.utils import safe_hasattr
from Products.CMFCore.utils import getToolByName
from Products.CMFDiffTool.ChangeSet import BaseChangeSet
Expand All @@ -26,6 +27,10 @@ def setUp(self):
# ChangeSet needs an acquisition wrapper
self.cs = cs.__of__(self.portal)
setRoles(self.portal, TEST_USER_ID, ["Contributor"])
self.expected_diff_len = 13
installer = get_installer(self.portal)
if installer.is_product_installed("plone.app.discussion"):
self.expected_diff_len += 1

def testInterface(self):
"""Ensure that tool instances implement the portal_diff interface"""
Expand Down Expand Up @@ -70,7 +75,7 @@ def testChangeSetFolderUnchanged(self):
self.setupTestFolders()
self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertTrue(diffs[0].same)
sub_cs = self.cs.getSubDiffs()
self.assertEqual(len(sub_cs), 3)
Expand All @@ -87,7 +92,7 @@ def testChangeSetFolderChanged(self):
self.folder.copy_of_folder1.setTitle("My New Title")
self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertFalse(diffs[0].same)
self.assertEqual(
diffs[0].ndiff(), "- My Folder Title%s+ My New Title" % linesep
Expand All @@ -108,7 +113,7 @@ def testChangeSetFolderDocChanged(self):
self.folder.copy_of_folder1.doc1.setTitle("My New Title")
self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertTrue(diffs[0].same)
self.assertTrue(diffs[1].same)
self.assertFalse(self.cs._added)
Expand All @@ -133,7 +138,7 @@ def testChangeSetFolderDocRemoved(self):
self.folder.copy_of_folder1.manage_delObjects("doc1")
self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertTrue(diffs[0].same)
self.assertTrue(diffs[1].same)
sub_cs = self.cs.getSubDiffs()
Expand All @@ -155,7 +160,7 @@ def testChangeSetFolderDocAdded(self):
)
self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertTrue(diffs[0].same)
self.assertTrue(diffs[1].same)
sub_cs = self.cs.getSubDiffs()
Expand All @@ -180,7 +185,7 @@ def testChangeSetFolderReordered(self):
return
self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertTrue(diffs[0].same)
self.assertFalse(self.cs._added)
self.assertFalse(self.cs._removed)
Expand Down Expand Up @@ -217,7 +222,7 @@ def testChangeSetFolderComplex(self):

self.cs.computeDiff(self.folder["folder1"], self.folder["copy_of_folder1"])
diffs = self.cs.getDiffs()
self.assertEqual(len(diffs), 14)
self.assertEqual(len(diffs), self.expected_diff_len)
self.assertFalse(diffs[0].same)
self.assertEqual(
diffs[0].ndiff(), "- My Folder Title%s+ My New Title" % linesep
Expand Down
1 change: 1 addition & 0 deletions news/57.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix tests to run with plone.app.discussion as core add-on. [@jensens]

0 comments on commit ee216d1

Please sign in to comment.