示例#1
0
 def test_video_block_produces_block(self):
     video_file = SimpleUploadedFile("downtest.mov", b"\x00\x01\x02\x03")
     video = MediaFile.objects.create(mediatitle="test", mediafile=video_file)
     try:
         self.assertTrue(samdown.process_block("[VIDEO](test)").startswith(
          "<video src="))
         self.assertIn("%s.mov" % datetime.datetime.now().strftime("%Y%m%d"), samdown.process_block("[VIDEO](test)"))
     finally:
         video.delete()
示例#2
0
 def test_img_block_produces_image(self):
     media_file = SimpleUploadedFile("downtest.png", b"\x00\x01\x02\x03")
     image = MediaFile.objects.create(mediatitle="test", mediafile=media_file)
     try:
         self.assertTrue(samdown.process_block("[IMAGE](test)").startswith(
          "<figure><img"))
         self.assertIn("%s.png" % datetime.datetime.now().strftime("%Y%m%d"), samdown.process_block("[IMAGE](test)"))
     finally:
         image.delete()
示例#3
0
 def test_underline_processing(self):
     self.assertEqual(
      samdown.process_block("_Some_ underlined text"),
      "<p><u>Some</u> underlined text</p>"
     )
     self.assertEqual(
      samdown.process_block("_Some_ _underlined_ text"),
      "<p><u>Some</u> <u>underlined</u> text</p>"
     )
     self.assertEqual(
      samdown.process_block("Some underlined _text_"),
      "<p>Some underlined <u>text</u></p>"
     )
示例#4
0
 def test_bold_processing(self):
     self.assertEqual(
      samdown.process_block("**Some** bold text"),
      "<p><b>Some</b> bold text</p>"
     )
     self.assertEqual(
      samdown.process_block("**Some** **bold** text"),
      "<p><b>Some</b> <b>bold</b> text</p>"
     )
     self.assertEqual(
      samdown.process_block("Some bold **text**"),
      "<p>Some bold <b>text</b></p>"
     )
示例#5
0
 def test_italics_processing(self):
     self.assertEqual(
      samdown.process_block("*Some* italics text"),
      "<p><em>Some</em> italics text</p>"
     )
     self.assertEqual(
      samdown.process_block("*Some* *italics* text"),
      "<p><em>Some</em> <em>italics</em> text</p>"
     )
     self.assertEqual(
      samdown.process_block("Some italics *text*"),
      "<p>Some italics <em>text</em></p>"
     )
示例#6
0
 def test_img_alt_text_and_caption(self):
     self.assertIn(
      'title="ALT TEXT"',
      samdown.process_block('[IMAGE](xxxxx A:"ALT TEXT" C:"A CAPTION")')
     )
     self.assertIn(
      '<figcaption>A CAPTION</figcaption>',
      samdown.process_block('[IMAGE](xxxxx A:"ALT TEXT" C:"A CAPTION")')
     )
     self.assertIn(
      'title="ALT TEXT"',
      samdown.process_block('[IMAGE](xxxxx C:"A CAPTION" A:"ALT TEXT")')
     )
     self.assertIn(
      '<figcaption>A CAPTION</figcaption>',
      samdown.process_block('[IMAGE](xxxxx C:"A CAPTION" A:"ALT TEXT")')
     )
示例#7
0
 def test_plain_block_returns_plain_p(self):
     self.assertEqual(
      samdown.process_block("A paragraph"),
      "<p>A paragraph</p>"
     )
示例#8
0
 def test_img_caption_text(self):
     self.assertIn(
      '<figcaption>A CAPTION</figcaption>',
      samdown.process_block('[IMAGE](xxxxx C:"A CAPTION")')
     )
示例#9
0
 def test_img_alt_text(self):
     self.assertIn(
      'title="ALT TEXT"',
      samdown.process_block('[IMAGE](xxxxx A:"ALT TEXT")')
     )
示例#10
0
 def test_youtube_block_produces_iframe(self):
     self.assertTrue(samdown.process_block("[YOUTUBE](xxxxx)").startswith(
      "<div class=\"youtube\"><iframe"))
示例#11
0
 def test_normal_block_produces_paragraph(self):
     self.assertTrue(samdown.process_block("...").startswith("<p>"))
     self.assertTrue(samdown.process_block("[YOUTUBE](xxxx).").startswith("<p>"))
     self.assertTrue(samdown.process_block(".[YOUTUBE](xxxx)").startswith("<p>"))
示例#12
0
 def test_multiple_hyperlink_translation(self):
     self.assertEqual(
      samdown.process_block("A [link](http://test.com)[.](/about/)"),
      "<p>A <a href=\"http://test.com\">link</a><a href=\"/about/\">.</a></p>"
     )
示例#13
0
 def test_hyperlink_translation(self):
     self.assertEqual(
      samdown.process_block("A [link](http://test.com)."),
      "<p>A <a href=\"http://test.com\">link</a>.</p>"
     )
示例#14
0
 def test_mixed_formatting(self):
     self.assertEqual(
      samdown.process_block("_Some_ *formatted* **text***"),
      "<p><u>Some</u> <em>formatted</em> <b>text</b>*</p>"
     )