コード例 #1
0
    def test_expand_db_attributes_for_editor(self):
        result = PageLinkHandler.expand_db_attributes({"id": 1}, True)
        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}, True)
        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}, True)
        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},
                                                      True)
        self.assertEqual(
            result,
            '<a data-linktype="page" data-id="%d" data-parent-id="2" href="/events/">'
            % events_page_id)
コード例 #3
0
ファイル: test_rich_text.py プロジェクト: asmaps/wagtail
 def test_expand_db_attributes_for_editor(self):
     result = PageLinkHandler.expand_db_attributes(
         {'id': 1},
         True
     )
     self.assertEqual(result,
                      '<a data-linktype="page" data-id="1" href="None">')
コード例 #4
0
ファイル: test_rich_text.py プロジェクト: wengole/wagtail
 def test_expand_db_attributes_for_editor(self):
     result = PageLinkHandler.expand_db_attributes(
         {'id': 1},
         True
     )
     self.assertEqual(result,
                      '<a data-linktype="page" data-id="1" href="None">')
コード例 #5
0
ファイル: test_rich_text.py プロジェクト: asmaps/wagtail
 def test_get_db_attributes(self):
     soup = BeautifulSoup(
         '<a data-id="test-id">foo</a>'
     )
     tag = soup.a
     result = PageLinkHandler.get_db_attributes(tag)
     self.assertEqual(result,
                      {'id': 'test-id'})
コード例 #6
0
ファイル: test_rich_text.py プロジェクト: asmaps/wagtail
 def test_expand_db_attributes_not_for_editor(self):
     result = PageLinkHandler.expand_db_attributes(
         {'id': 1},
         False
     )
     self.assertEqual(result, '<a href="None">')
コード例 #7
0
ファイル: test_rich_text.py プロジェクト: asmaps/wagtail
 def test_expand_db_attributes_page_does_not_exist(self):
     result = PageLinkHandler.expand_db_attributes(
         {'id': 0},
         False
     )
     self.assertEqual(result, '<a>')
コード例 #8
0
ファイル: test_rich_text.py プロジェクト: zalphi/wagtail
 def test_expand_db_attributes_not_for_editor(self):
     result = PageLinkHandler.expand_db_attributes({'id': 1}, False)
     self.assertEqual(result, '<a href="None">')
コード例 #9
0
ファイル: test_rich_text.py プロジェクト: zalphi/wagtail
 def test_expand_db_attributes_page_does_not_exist(self):
     result = PageLinkHandler.expand_db_attributes({'id': 0}, False)
     self.assertEqual(result, '<a>')
コード例 #10
0
ファイル: test_rich_text.py プロジェクト: zalphi/wagtail
 def test_get_db_attributes(self):
     soup = BeautifulSoup('<a data-id="test-id">foo</a>')
     tag = soup.a
     result = PageLinkHandler.get_db_attributes(tag)
     self.assertEqual(result, {'id': 'test-id'})
コード例 #11
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"})