Skip to content

Commit

Permalink
conditional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Oct 10, 2024
1 parent 120ff2d commit 5408d3f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/plone/restapi/serializer/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ def __init__(self, context, request):
self.blocklisted_attributes = metadata["blocklisted_attributes"]

def __call__(self):
try:
obj = IContentListingObject(self.context)
except TypeError:
return {}
obj = IContentListingObject(self.context)

summary = {}
for field in self.metadata_fields():
Expand Down
26 changes: 25 additions & 1 deletion src/plone/restapi/tests/test_serializer_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

import Missing
import unittest
import pkg_resources


try:
from plone.app.event.adapters import OccurrenceContentListingObject
except ImportError:
OccurrenceContentListingObject = None


class TestSummarySerializers(unittest.TestCase):
Expand Down Expand Up @@ -245,7 +252,24 @@ def setUp(self):
def tearDown(self):
popGlobalRegistry(getSite())

def test_dx_event_with_recurrence(self):
@unittest.skipIf(
OccurrenceContentListingObject is not None,
"this test needs a plone.app.event version that does not include a IContentListingObject adapter",
)
def test_dx_event_with_recurrence_old_version(self):
tomorrow = datetime.now() + timedelta(days=1)
tomorrow_str = tomorrow.strftime("%Y-%m-%d")
ot = OccurrenceTraverser(self.event, self.request)
ocurrence = ot.publishTraverse(self.request, tomorrow_str)

with self.assertRaises(TypeError):
getMultiAdapter((ocurrence, self.request), ISerializeToJsonSummary)()

@unittest.skipIf(
OccurrenceContentListingObject is None,
"this test needs a plone.app.event version that includes a IContentListingObject adapter",
)
def test_dx_event_with_recurrence_new_version(self):
tomorrow = datetime.now() + timedelta(days=1)
tomorrow_str = tomorrow.strftime("%Y-%m-%d")
ot = OccurrenceTraverser(self.event, self.request)
Expand Down

0 comments on commit 5408d3f

Please sign in to comment.