Пример #1
0
    def test_expand_db_attributes_for_editor(self):
        result = PageLinkHandler.expand_db_attributes({'id': 1})
        self.assertEqual(result,
                         '<a data-linktype="page" data-id="1" href="None">')

        events_page_id = Page.objects.get(url_path='/home/events/').pk
        result = PageLinkHandler.expand_db_attributes({'id': events_page_id})
        self.assertEqual(
            result,
            '<a data-linktype="page" data-id="%d" data-parent-id="2" href="/events/">'
            % events_page_id)
Пример #2
0
    def test_expand_db_attributes_for_editor(self):
        result = PageLinkHandler.expand_db_attributes({'id': 1})
        self.assertEqual(
            result,
            '<a data-linktype="page" data-id="1" href="None">'
        )

        events_page_id = Page.objects.get(url_path='/home/events/').pk
        result = PageLinkHandler.expand_db_attributes({'id': events_page_id})
        self.assertEqual(
            result,
            '<a data-linktype="page" data-id="%d" data-parent-id="2" href="/events/">' % events_page_id
        )
Пример #3
0
 def test_get_db_attributes(self):
     soup = BeautifulSoup('<a data-id="test-id">foo</a>', 'html5lib')
     tag = soup.a
     result = PageLinkHandler.get_db_attributes(tag)
     self.assertEqual(result, {'id': 'test-id'})
Пример #4
0
 def test_get_db_attributes(self):
     soup = BeautifulSoup('<a data-id="test-id">foo</a>', 'html5lib')
     tag = soup.a
     result = PageLinkHandler.get_db_attributes(tag)
     self.assertEqual(result,
                      {'id': 'test-id'})