[test] Backport test for breadcrumbs related components from saem_ref
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 28 Feb 2017 22:41:46 +0100
changeset 2444 6dc0c6dbc771
parent 2443 75bd29a15521
child 2445 2577d5c14718
[test] Backport test for breadcrumbs related components from saem_ref
test/test_views.py
--- a/test/test_views.py	Tue Feb 28 22:40:09 2017 +0100
+++ b/test/test_views.py	Tue Feb 28 22:41:46 2017 +0100
@@ -600,5 +600,29 @@
                              [(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()