[PATCH 5 of 9 seda] [test] Backport test for breadcrumbs related components from saem_ref

Sylvain Thenault sylvain.thenault at logilab.fr
Wed Mar 1 12:31:47 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1488318106 -3600
#      Tue Feb 28 22:41:46 2017 +0100
# Node ID 719955d392330e64cfce90621e25fb5c3737efd4
# Parent  dd48a3b0eea1a36d22153f18fa6f14434fce64d4
[test] Backport test for breadcrumbs related components from saem_ref

diff --git a/test/test_views.py b/test/test_views.py
--- a/test/test_views.py
+++ b/test/test_views.py
@@ -598,7 +598,31 @@ class ArchiveUnitVocabularyTC(CubicWebTC
             form = FakeForm(req, bdo)
             self.assertEqual(archiveunit.do_ref_vocabulary(form, None),
                              [(u'data object title', text_type(bdo.eid))])
 
 
+class SEDANavigationTC(CubicWebTC):
+
+    def test_breadcrumbs(self):
+        with self.admin_access.cnx() as cnx:
+            transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
+            unit1 = testutils.create_archive_unit(transfer)[0]
+            unit2 = testutils.create_archive_unit(None, cnx=cnx)[0]
+            cnx.commit()
+        with self.admin_access.web_request() as req:
+            unit1 = req.entity_from_eid(unit1.eid)
+            unit2 = req.entity_from_eid(unit2.eid)
+            # unit1 is related to a transfer
+            breadcrumbs = unit1.cw_adapt_to('IBreadCrumbs').breadcrumbs()
+            expected_breadcrumbs = [transfer, unit1]
+            self.assertEqual(breadcrumbs, expected_breadcrumbs)
+            # unit2 is not related to a transfer, breadcrumbs leads to /sedalib.
+            breadcrumbs = unit2.cw_adapt_to('IBreadCrumbs').breadcrumbs()
+            expected_breadcrumbs = [
+                (u'http://testing.fr/cubicweb/sedalib', u'SEDAArchiveUnit_plural'),
+                unit2,
+            ]
+            self.assertEqual(breadcrumbs, expected_breadcrumbs)
+
+
 if __name__ == '__main__':
     unittest.main()


More information about the saem-devel mailing list