示例#1
0
 def test_annotate_links_no_site(self):
     site = Site.objects.get(is_default_site=True)
     site.is_default_site = False
     site.save()
     with self.assertRaises(RuntimeError) as context:
         annotate_links('answer')
     self.assertIn('no default wagtail site', str(context.exception))
示例#2
0
 def test_annotate_links_no_site(self):
     site = Site.objects.get(is_default_site=True)
     site.is_default_site = False
     site.save()
     with self.assertRaises(RuntimeError) as context:
         annotate_links('answer')
     self.assertIn('no default wagtail site', str(context.exception))
示例#3
0
 def test_annotate_links(self):
     mock_answer = (
         '<p>Answer with a <a href="http://fake.com">fake link.</a></p>')
     (annotated_answer, links) = annotate_links(mock_answer)
     self.assertEqual(
         annotated_answer,
         '<html><body><p>Answer with a <a href="http://fake.com">fake '
         'link.</a><sup>1</sup></p></body></html>')
     self.assertEqual(links, [(1, str('http://fake.com'))])
示例#4
0
 def test_annotate_links(self):
     mock_answer = (
         '<p>Answer with a <a href="http://fake.com">fake link.</a></p>')
     (annotated_answer, links) = annotate_links(mock_answer)
     self.assertEqual(
         annotated_answer,
         '<html><body><p>Answer with a <a href="http://fake.com">fake '
         'link.</a><sup>1</sup></p></body></html>')
     self.assertEqual(links, [(1, str('http://fake.com'))])
示例#5
0
 def test_annotate_links_no_href(self):
     mock_answer = ('<p>Answer with a <a>fake link.</a></p>')
     (annotated_answer, links) = annotate_links(mock_answer)
     self.assertEqual(links, [])
示例#6
0
 def test_annotate_links_no_href(self):
     mock_answer = (
         '<p>Answer with a <a>fake link.</a></p>')
     (annotated_answer, links) = annotate_links(mock_answer)
     self.assertEqual(links, [])