|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | """Setup tests for this package.""" |
| 3 | + |
3 | 4 | from design.plone.contenttypes.testing import ( |
4 | 5 | DESIGN_PLONE_CONTENTTYPES_API_FUNCTIONAL_TESTING, |
5 | 6 | ) |
6 | 7 | from plone import api |
| 8 | +from plone.app.linkintegrity.utils import getIncomingLinks |
| 9 | +from plone.app.linkintegrity.utils import getOutgoingLinks |
7 | 10 | from plone.app.testing import setRoles |
8 | 11 | from plone.app.testing import SITE_OWNER_NAME |
9 | 12 | from plone.app.testing import SITE_OWNER_PASSWORD |
@@ -338,6 +341,38 @@ def test_servizio_fields_seo_fieldset(self): |
338 | 341 | ], |
339 | 342 | ) |
340 | 343 |
|
| 344 | + def test_canale_digitale_link_to_object_generate_reference(self): |
| 345 | + doc = api.content.create(container=self.portal, type="Document", title="doc") |
| 346 | + |
| 347 | + self.assertEqual(len(list(getIncomingLinks(doc))), 0) |
| 348 | + |
| 349 | + servizio = api.content.create( |
| 350 | + container=self.portal, |
| 351 | + type="Servizio", |
| 352 | + title="servizio", |
| 353 | + canale_digitale_link=f"${{portal_url}}/resolveuid/{doc.UID()}", |
| 354 | + ) |
| 355 | + self.assertEqual(len(list(getIncomingLinks(doc))), 1) |
| 356 | + self.assertEqual([x.from_object for x in getIncomingLinks(doc)], [servizio]) |
| 357 | + |
| 358 | + self.assertEqual(len(list(getOutgoingLinks(servizio))), 1) |
| 359 | + self.assertEqual([x.to_object for x in getOutgoingLinks(servizio)], [doc]) |
| 360 | + |
| 361 | + def test_canale_digitale_link_to_external_do_not_generate_reference(self): |
| 362 | + doc = api.content.create(container=self.portal, type="Document", title="doc") |
| 363 | + |
| 364 | + self.assertEqual(len(list(getIncomingLinks(doc))), 0) |
| 365 | + |
| 366 | + servizio = api.content.create( |
| 367 | + container=self.portal, |
| 368 | + type="Servizio", |
| 369 | + title="servizio", |
| 370 | + canale_digitale_link="https://www.plone.org", |
| 371 | + ) |
| 372 | + self.assertEqual(len(list(getIncomingLinks(doc))), 0) |
| 373 | + |
| 374 | + self.assertEqual(len(list(getOutgoingLinks(servizio))), 0) |
| 375 | + |
341 | 376 |
|
342 | 377 | class TestServizioApi(unittest.TestCase): |
343 | 378 | """Test that design.plone.contenttypes is properly installed.""" |
|
0 commit comments