def testHTMLBodyWithRawHTMLMarker(self): post = Post( body= '<p>First paragraph!</p><p>===</p><iframe src="wat"></iframe><p>===</p><p>Second!</p>' ) self.assertEqual( post.html_body, '<p>First paragraph!</p><iframe src="wat"></iframe><p>Second!</p>')
def testHTMLBodyWithTwoRawHTMLMarkers(self): post = Post( body= '<p>First paragraph!</p><p> ===</p><iframe src="wat"></iframe><p>===\t</p><p>Second!</p><p>===</p><strong>test</strong><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>' )
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, )
def testSlugAutoSet(self): post = Post(title='Hello There!') self.assertEqual(post.slug, 'hello-there')
def testImageURL(self): post = Post( body='<p>First paragraph!</p><p><img src="/images/wat"></p>') self.assertEqual(post.image_url, '/images/wat')
def testImageURLNoImage(self): post = Post(body='<p>First paragraph!</p><p>Second!</p>') self.assertIsNone(post.image_url)
def testDescription(self): post = Post(body='<p>First paragraph!</p><p>Second!</p>') self.assertEqual(post.description, 'First paragraph!')
def testSummaryNoPTag(self): post = Post(body='Just some garbage in here.') self.assertEqual(post.summary, post.body)
def testSummary(self): post = Post(body='<p>First paragraph!</p><p>Second!</p>') self.assertEqual(post.summary, '<p>First paragraph!</p>')
def testRepr(self): post = Post(title='Hello There!') self.assertEqual(str(post), '<Post Hello There!>')
def testSlugManualSet(self): post = Post(title='Hello There!', slug='different') self.assertEqual(post.slug, 'different')