Ejemplo n.º 1
0
 def test_expand_db_attributes_autolocalizes(self):
     # Even though it's linked to the english page in rich text.
     # The link should be to the local language version if it's available
     with translation.override("fr"):
         result = PageLinkHandler.expand_db_attributes(
             {"id": self.event_page.id})
         self.assertEqual(result, '<a href="/fr/events/noel/">')
Ejemplo n.º 2
0
    def test_expand_db_attributes_doesnt_autolocalize_unpublished_page(self):
        # We shouldn't autolocalize if the translation is unpublished
        self.fr_event_page.unpublish()
        self.fr_event_page.save()

        with translation.override("fr"):
            result = PageLinkHandler.expand_db_attributes({"id": self.event_page.id})
            self.assertEqual(result, '<a href="/en/events/christmas/">')
Ejemplo n.º 3
0
 def test_expand_db_attributes(self):
     result = PageLinkHandler.expand_db_attributes(
         {"id": self.event_page.id})
     self.assertEqual(result, '<a href="/en/events/christmas/">')
Ejemplo n.º 4
0
 def test_expand_db_attributes_not_for_editor(self):
     result = PageLinkHandler.expand_db_attributes({"id": 1})
     self.assertEqual(result, '<a href="None">')
Ejemplo n.º 5
0
 def test_expand_db_attributes_page_does_not_exist(self):
     result = PageLinkHandler.expand_db_attributes({"id": 0})
     self.assertEqual(result, "<a>")
Ejemplo n.º 6
0
 def test_expand_db_attributes(self):
     result = PageLinkHandler.expand_db_attributes(
         {"id": Page.objects.get(url_path="/home/events/christmas/").id})
     self.assertEqual(result, '<a href="/events/christmas/">')