Skip to content

Commit 12843ae

Browse files
committed
Add unit tests for Modulo mime type handling and cache refresh
1 parent a5bd66b commit 12843ae

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/design/plone/contenttypes/tests/test_upgrade_to_7321.py renamed to src/design/plone/contenttypes/tests/test_modulo_mime_type.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import unittest
1313

1414

15-
class TestUpgradeTo7321(unittest.TestCase):
15+
class TestModuloMimeType(unittest.TestCase):
1616
layer = DESIGN_PLONE_CONTENTTYPES_INTEGRATION_TESTING
1717

1818
def setUp(self):
@@ -39,6 +39,16 @@ def setUp(self):
3939
contentType="application/pdf",
4040
),
4141
)
42+
self.modulo_2 = api.content.create(
43+
container=self.documento,
44+
type="Modulo",
45+
title="Modulo_2",
46+
file_principale=NamedBlobFile(
47+
data=pdf_data,
48+
filename="example.pdf",
49+
contentType="application/pdf",
50+
),
51+
)
4252
self.enhancedlinks_tool = api.portal.get_tool("portal_enhancedlinks")
4353
# Simulate the stale cache entry that the upgrade has to refresh.
4454
self.enhancedlinks_tool._enhanced_links[self.modulo.UID()] = {
@@ -61,3 +71,12 @@ def test_to_7321_refreshes_modulo_mime_type_cache(self):
6171
self.enhancedlinks_tool.get_enhanced_link(self.modulo.UID())["mime_type"],
6272
"application/pdf",
6373
)
74+
75+
def test_modulo_mime_type_indexer(self):
76+
# The indexer should return the correct mime type for the Modulo.
77+
78+
catalog = api.portal.get_tool("portal_catalog")
79+
results = catalog(UID=self.modulo_2.UID())
80+
brain = results[0]
81+
82+
self.assertEqual(brain.mime_type, "application/pdf")

0 commit comments

Comments
 (0)