|
31 | 31 | from plone.namedfile.file import NamedBlobFile |
32 | 32 | from z3c.relationfield.relation import RelationValue |
33 | 33 | from zc.relation.interfaces import ICatalog |
34 | | -from zope.annotation.interfaces import IAnnotations |
35 | 34 | from zope.component import getUtility |
36 | 35 | from zope.interface import Invalid |
37 | 36 | from zope.intid.interfaces import IIntIds |
@@ -643,43 +642,3 @@ def test_AssignedUserValidator(self): |
643 | 642 | self.assertRaises(Invalid, auv.validate, "agent1") |
644 | 643 | # we check assigned_user requirement if the imail state will be changed |
645 | 644 | # this test is done in im wfadaptation test |
646 | | - |
647 | | - def test_ImioDmsOutgoingMail_copy_dms_files(self): |
648 | | - """Test ImioDmsOutgoingMail.copy_dms_files""" |
649 | | - # Create fresh source and destination mails |
650 | | - original = sub_create(self.portal["outgoing-mail"], "dmsoutgoingmail", datetime.now(), "test-orig-dms") |
651 | | - pc = api.portal.get_tool("portal_catalog") |
652 | | - |
653 | | - # No dmsommainfile on original → copy_dms_files is a no-op |
654 | | - new_mail = sub_create(self.portal["outgoing-mail"], "dmsoutgoingmail", datetime.now(), "test-copy-dms-1") |
655 | | - new_mail.mail_date = date.today() |
656 | | - new_mail.copy_dms_files(original) |
657 | | - self.assertEqual(len(pc(portal_type="dmsommainfile", path="/".join(new_mail.getPhysicalPath()))), 0) |
658 | | - |
659 | | - # Add a dmsommainfile without documentgenerator annotation → direct copy |
660 | | - new_mail2 = sub_create(self.portal["outgoing-mail"], "dmsoutgoingmail", datetime.now(), "test-copy-dms-2") |
661 | | - new_mail2.mail_date = date.today() |
662 | | - filename = u"Réponse salle.odt" |
663 | | - with open("%s/batchimport/toprocess/outgoing-mail/%s" % (PRODUCT_DIR, filename), "rb") as fo: |
664 | | - mainfile = createContentInContainer( |
665 | | - original, "dmsommainfile", file=NamedBlobFile(fo.read(), filename=filename)) |
666 | | - self.assertNotIn("documentgenerator", IAnnotations(mainfile)) |
667 | | - new_mail2.copy_dms_files(original) |
668 | | - self.assertEqual(len([s for s in new_mail2.values() if s.portal_type == "dmsommainfile"]), 1) |
669 | | - |
670 | | - # Add a dmsommainfile generated from a template → regenerate the file on new_mail |
671 | | - new_mail3 = sub_create(self.portal["outgoing-mail"], "dmsoutgoingmail", datetime.now(), "test-copy-dms-3") |
672 | | - new_mail3.mail_date = date.today() |
673 | | - dgv = getMultiAdapter((original, self.request), name="persistent-document-generation") |
674 | | - template_uid = self.portal["templates"]["om"]["main"].UID() |
675 | | - dgv(template_uid=template_uid, output_format='odt') |
676 | | - new_mail3.copy_dms_files(original) |
677 | | - self.assertEqual(len(pc(portal_type="dmsommainfile", path="/".join(new_mail3.getPhysicalPath()))), 1) |
678 | | - |
679 | | - # mail_date missing on new_mail → gets copied from original (with warn message) |
680 | | - new_mail4 = sub_create(self.portal["outgoing-mail"], "dmsoutgoingmail", datetime.now(), "test-copy-dms-4") |
681 | | - original.mail_date = date(2024, 1, 15) |
682 | | - self.assertIsNone(new_mail4.mail_date) |
683 | | - new_mail4.copy_dms_files(original) |
684 | | - self.assertEqual(new_mail4.mail_date, date(2024, 1, 15)) |
685 | | - self.assertEqual(len(pc(portal_type="dmsommainfile", path="/".join(new_mail4.getPhysicalPath()))), 1) |
0 commit comments