예제 #1
0
 def testHTMLBodyWithRawHTMLMarker(self):
     post = Post(
         body=
         '<p>First paragraph!</p><p>===</p>&lt;iframe src="wat"&gt;&lt;/iframe&gt;<p>===</p><p>Second!</p>'
     )
     self.assertEqual(
         post.html_body,
         '<p>First paragraph!</p><iframe src="wat"></iframe><p>Second!</p>')
예제 #2
0
 def testHTMLBodyWithTwoRawHTMLMarkers(self):
     post = Post(
         body=
         '<p>First paragraph!</p><p> ===</p>&lt;iframe src="wat"&gt;&lt;/iframe&gt;<p>===\t</p><p>Second!</p><p>===</p>&lt;strong&gt;test&lt;/strong&gt;<p>===</p><p>Third!</p>'
     )
     self.assertEqual(
         post.html_body,
         '<p>First paragraph!</p><iframe src="wat"></iframe><p>Second!</p><strong>test</strong><p>Third!</p>'
     )
예제 #3
0
 def to_post(self, user=None):
     tags = self._find_or_build_tags()
     published_at = self._get_published_at()
     return Post(
         title=self.title.data,
         slug=self.slug.data,
         body=self.body.data,
         published_at=published_at,
         user=user,
         tags=tags,
     )
예제 #4
0
 def testSlugAutoSet(self):
     post = Post(title='Hello There!')
     self.assertEqual(post.slug, 'hello-there')
예제 #5
0
 def testImageURL(self):
     post = Post(
         body='<p>First paragraph!</p><p><img src="/images/wat"></p>')
     self.assertEqual(post.image_url, '/images/wat')
예제 #6
0
 def testImageURLNoImage(self):
     post = Post(body='<p>First paragraph!</p><p>Second!</p>')
     self.assertIsNone(post.image_url)
예제 #7
0
 def testDescription(self):
     post = Post(body='<p>First paragraph!</p><p>Second!</p>')
     self.assertEqual(post.description, 'First paragraph!')
예제 #8
0
 def testSummaryNoPTag(self):
     post = Post(body='Just some garbage in here.')
     self.assertEqual(post.summary, post.body)
예제 #9
0
 def testSummary(self):
     post = Post(body='<p>First paragraph!</p><p>Second!</p>')
     self.assertEqual(post.summary, '<p>First paragraph!</p>')
예제 #10
0
 def testRepr(self):
     post = Post(title='Hello There!')
     self.assertEqual(str(post), '<Post Hello There!>')
예제 #11
0
 def testSlugManualSet(self):
     post = Post(title='Hello There!', slug='different')
     self.assertEqual(post.slug, 'different')