From 61eb3129deae12021b1225a15f097959ef2d1317 Mon Sep 17 00:00:00 2001 From: Andrea Cecchi Date: Tue, 27 Aug 2024 16:12:33 +0200 Subject: [PATCH] add test --- redturtle/bandi/tests/example.txt | 1 + redturtle/bandi/tests/test_bando_view.py | 30 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 redturtle/bandi/tests/example.txt diff --git a/redturtle/bandi/tests/example.txt b/redturtle/bandi/tests/example.txt new file mode 100644 index 0000000..d6459e0 --- /dev/null +++ b/redturtle/bandi/tests/example.txt @@ -0,0 +1 @@ +xxx diff --git a/redturtle/bandi/tests/test_bando_view.py b/redturtle/bandi/tests/test_bando_view.py index 33987e3..b3838de 100644 --- a/redturtle/bandi/tests/test_bando_view.py +++ b/redturtle/bandi/tests/test_bando_view.py @@ -3,7 +3,9 @@ from plone import api from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID +from plone.namedfile.file import NamedBlobFile +import os import unittest @@ -105,3 +107,31 @@ def test_tipologia_bando_in_right_view(self): ) self.assertIn("Announcement type", view_new()) self.assertIn("Altro", view_new()) + + def test_dates_in_attachments(self): + folder = api.content.create( + container=self.bando, type="Bando Folder Deepening", title="attachments" + ) + + filename = os.path.join(os.path.dirname(__file__), "example.txt") + api.content.create( + container=folder, + type="File", + title="attachment", + file=NamedBlobFile( + data=open(filename, "rb").read(), + filename="example.txt", + contentType="text/plain", + ), + ) + + view = api.content.get_view( + name="bando_view", context=self.bando, request=self.request + ) + data = view.retrieveContentsOfFolderDeepening( + "/".join(folder.getPhysicalPath()) + ) + + self.assertEqual(len(data), 1) + self.assertIn("modified", data[0]) + self.assertIn("effective", data[0])