本文整理汇总了Python中blogengine.models.Post.text方法的典型用法代码示例。如果您正苦于以下问题:Python Post.text方法的具体用法?Python Post.text怎么用?Python Post.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blogengine.models.Post
的用法示例。
在下文中一共展示了Post.text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_index(self):
# Create the post
post = Post()
post.title = 'My first post'
post.text = 'This is [my first blog post](http://127.0.0.1:8000/)'
post.slug = 'my-first-post'
post.pub_date = timezone.now()
post.save()
# Check new post saved
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
# Fetch the index
response = self.client.get('/')
self.assertEquals(response.status_code, 200)
# Check the post title is in the response
self.assertTrue(post.title in response.content)
# Check the post text is in the response
self.assertTrue(markdown2.markdown(post.text) in force_unicode(response.content))
# Check the post date is in the response
self.assertTrue(str(post.pub_date.year) in response.content)
self.assertTrue(str(post.pub_date.day) in response.content)
# Check the link is marked up properly
self.assertTrue('<a href="http://127.0.0.1:8000/">my first blog post</a>' in response.content)
示例2: test_create_post
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_create_post(self):
# Create the post
post = Post()
# Set the attributes
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
# Save it
post.save()
# Check we can find it
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
# Check attributes
self.assertEquals(only_post.title, 'My first post')
self.assertEquals(only_post.text, 'This is my first blog post')
self.assertEquals(only_post.pub_date.day, post.pub_date.day)
self.assertEquals(only_post.pub_date.month, post.pub_date.month)
self.assertEquals(only_post.pub_date.year, post.pub_date.year)
self.assertEquals(only_post.pub_date.hour, post.pub_date.hour)
self.assertEquals(only_post.pub_date.minute, post.pub_date.minute)
self.assertEquals(only_post.pub_date.second, post.pub_date.second)
示例3: test_create_post_
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_create_post_(self):
author = User.objects.create_user('testuser', '[email protected]', 'password')
author.save()
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.slug = 'my-first-post'
post.pub_date = timezone.now()
post.author = author
post.save()
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
self.assertEquals(only_post.title, 'My first post')
self.assertEquals(only_post.text, 'This is my first blog post')
self.assertEquals(only_post.slug, 'my-first-post')
self.assertEquals(only_post.pub_date.day, post.pub_date.day)
self.assertEquals(only_post.pub_date.month, post.pub_date.month)
self.assertEquals(only_post.pub_date.year, post.pub_date.year)
self.assertEquals(only_post.pub_date.hour, post.pub_date.hour)
self.assertEquals(only_post.pub_date.minute, post.pub_date.minute)
self.assertEquals(only_post.pub_date.second, post.pub_date.second)
self.assertEquals(only_post.author.username, 'testuser')
self.assertEquals(only_post.author.email, '[email protected]')
示例4: test_post_page
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_post_page(self):
author = User.objects.create_user('testuser', '[email protected]', 'password')
author.save()
post = Post()
post.title = "My first post"
post.text = 'This is [my first blog post](http://127.0.0.1:8000/)'
post.pub_date = timezone.now()
post.slug = 'my-first-post'
post.author = author
post.save()
all_posts = Post.objects.all()
self.assertEquals(len(all_posts),1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
post_url = only_post.get_absolute_url()
response = self.client.get(post_url)
self.assertEquals(response.status_code, 200)
self.assertTrue(post.title in response.content)
self.assertTrue(markdown.markdown(post.text) in response.content)
self.assertTrue(str(post.pub_date.year) in response.content)
self.assertTrue(post.pub_date.strftime('%b') in response.content)
self.assertTrue(str(post.pub_date.day) in response.content)
self.assertTrue('<a href="http://127.0.0.1:8000/">my first blog post</a>' in response.content)
示例5: test_edit_post
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_edit_post(self):
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
post.save()
# Log in
self.client.login(username='bobsmith', password='password')
response = self.client.post('/admin/blogengine/post/1/', {
'title': 'My second post',
'text': 'This is my second post',
'pub_date_0': '2014-06-10',
'pub_date_1': '21:00:02',
'slug' : 'my-second-post'
},
follow=True
)
self.assertEquals(response.status_code, 200)
self.assertTrue('changed successfully' in response.content)
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post.title, 'My second post')
self.assertEquals(only_post.text, 'This is my second post')
示例6: test_category_page
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_category_page(self):
category = Category()
category.name = 'python'
category.description = 'The Python programming language'
category.save()
site = Site()
site.name = 'example.com'
site.domain = 'example.com'
site.save()
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
post.slug = 'my-first-post'
post.site = site
post.category = category
post.save()
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
category_url = post.category.get_absolute_url()
# Fetch the category
response = self.client.get(category_url)
self.assertEquals(response.status_code, 200)
self.assertTrue(post.category.name in response.content)
self.assertTrue(post.title in response.content)
示例7: test_index
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_index(self):
# Create the category
category = Category()
category.name = 'python'
category.description = 'The Python programming language'
category.save()
# Create the author
author = User.objects.create_user('testuser', '[email protected]', 'password')
author.save()
# Create the site
site = Site()
site.name = 'example.com'
site.domain = 'example.com'
site.save()
# Create the post
post = Post()
post.title = 'My first post'
post.text = 'This is [my first blog post](http://127.0.0.1:8000/)'
post.slug = 'my-first-post'
post.pub_date = timezone.now()
post.author = author
post.site = site
post.category = category
post.save()
# Check new post saved
all_posts = Post.objects.all()
self.assertEqual(len(all_posts), 1)
# Fetch the index
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
示例8: test_index
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_index(self):
# Create the post
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
post.save()
# Check new post saved
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
# Fetch the test_index
response = self.client.get('/')
self.assertEquals(response.status_code, 200)
# Check the post title is in the response
self.assertTrue(post.title in response.content)
# Check the post text is in the response
self.assertTrue(post.text in response.content)
# Check the post date is in the response
self.assertTrue(str(post.pub_date.year) in response.content)
self.assertTrue(post.pub_date.strftime('%b') in response.content)
self.assertTrue(str(post.pub_date.day) in response.content)
示例9: test_edit_post
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_edit_post(self):
# Create the post
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
post.save()
# Log in
self.client.login(username='thedoctor', password="#EDC4rfv")
# Edit the post
response = self.client.post('/admin/blogengine/post/1/', {
'title': 'My second post',
'text': 'This is my second blog post',
'pub_date_0': '2013-12-28',
'pub_date_1': '22:00:04'
},
follow=True
)
self.assertEquals(response.status_code, 200)
# Check changed successfully
self.assertTrue('changed successfully' in response.content)
# Check post amended
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post.title, 'My second post')
self.assertEquals(only_post.text, 'This is my second blog post')
示例10: test_tag_page
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_tag_page(self):
# Create the tag
tag = CreateTag()
# Create the post
post = Post()
post.title = 'My first post'
post.text = 'This is [my first blog post](http://127.0.0.1:8000/)'
post.slug = 'my-first-post'
post.pub_date = timezone.now()
post.save()
post.tags.add(tag)
post.save()
# Check new post saved
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
# Get the tag URL
tag_url = post.tags.all()[0].get_absolute_url()
# Fetch the tag
response = self.client.get(tag_url)
self.assertEquals(response.status_code, 200)
# Check the tag name is in the response
self.assertTrue(post.tags.all()[0].name in response.content)
# Check the post text is in the response
self.assertTrue(markdown.markdown(post.text) in response.content)
# Check the post date is in the response
self.assertTrue(str(post.pub_date.year) in response.content)
self.assertTrue(post.pub_date.strftime('%b') in response.content)
self.assertTrue(str(post.pub_date.day) in response.content)
# Check the link is marked up properly
self.assertTrue('<a href="http://127.0.0.1:8000/">my first blog post</a>' in response.content)
示例11: test_edit_post
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_edit_post(self):
CreateCategory()
tag = CreateTag()
post = Post()
post.title = 'My first post'
post.text = 'Hello World'
post.pub_date = timezone.now()
post.save()
post.tags.add(tag)
post.save()
self.client.login(username='ali', password='alikat')
# Edit the post
response = self.client.post(
'/admin/blogengine/post/1/', {
'title': 'My second post',
'text': 'Hello world part 2',
'pub_date_0': '2014-07-12',
'pub_date_1': '22:00:00',
'category': '1',
'tags': '1'},
follow=True
)
self.assertEquals(response.status_code, 200)
# Check changed successfully
self.assertTrue('changed successfully' in response.content)
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post.title, 'My second post')
self.assertEqual(only_post.text, 'Hello world part 2')
示例12: test_create_post
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_create_post(self):
category = CreateCategory()
tag = CreateTag()
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
post.category = category
post.save()
post.tags.add(tag)
post.save()
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
self.assertEquals(only_post, post)
self.assertEquals(only_post.title, 'My first post')
self.assertEquals(only_post.text, 'This is my first blog post')
self.assertEquals(only_post.pub_date.day, post.pub_date.day)
self.assertEquals(only_post.pub_date.month, post.pub_date.month)
self.assertEquals(only_post.pub_date.year, post.pub_date.year)
self.assertEquals(only_post.pub_date.hour, post.pub_date.hour)
self.assertEquals(only_post.pub_date.minute, post.pub_date.minute)
self.assertEquals(only_post.pub_date.second, post.pub_date.second)
self.assertEquals(only_post.category.name, 'Robots')
示例13: test_all_post_feed
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_all_post_feed(self):
# Create the category
category = Category()
category.name = 'python'
category.description = 'The Python programming language'
category.save()
# Create the tag
tag = Tag()
tag.name = 'python'
tag.description = 'The Python programming language'
tag.save()
# Create the author
author = User.objects.create_user('testuser', '[email protected]', 'password')
author.save()
# Create the site
site = Site()
site.name = 'example.com'
site.domain = 'example.com'
site.save()
# Create a post
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.slug = 'my-first-post'
post.pub_date = timezone.now()
post.author = author
post.site = site
post.category = category
# Save it
post.save()
# Add the tag
post.tags.add(tag)
post.save()
# Check we can find it
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
# Fetch the feed
response = self.client.get('/feeds/posts/')
self.assertEquals(response.status_code, 200)
# Parse the feed
feed = feedparser.parse(response.content)
# Check length
self.assertEquals(len(feed.entries), 1)
# Check post retrieved is the correct one
feed_post = feed.entries[0]
self.assertEquals(feed_post.title, post.title)
self.assertEquals(feed_post.description, post.text)
示例14: test_delete_post
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_delete_post(self):
# Create the post
post = Post()
post.title = 'My first post'
post.text = 'This is my first blog post'
post.pub_date = timezone.now()
post.save()
# Check new post saved
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 1)
# Log in
self.client.login(username='thedoctor', password="#EDC4rfv")
# Delete the post
response = self.client.post('/admin/blogengine/post/1/delete/', {
'post': 'yes'
}, follow=True)
self.assertEquals(response.status_code, 200)
# Check deleted successfully
self.assertTrue('deleted successfully' in response.content)
# Check post amended
all_posts = Post.objects.all()
self.assertEquals(len(all_posts), 0)
示例15: test_tag_page
# 需要导入模块: from blogengine.models import Post [as 别名]
# 或者: from blogengine.models.Post import text [as 别名]
def test_tag_page(self):
tag = Tag()
tag.name = 'python'
tag.description = 'python'
tag.save()
author = User.objects.create_user('testuser','[email protected]','password')
author.save()
post = Post()
post.title = 'first post'
post.text = 'fir post'
post.slug = 'first-post'
post.pub_date = timezone.now()
post.author = author
post.save()
post.tags.add(tag)
post.save()
self.assertEquals(len(Post.objects.all()),1)
self.assertEquals(Post.objects.all()[0],post)
r = self.client.get(post.tags.all()[0].get_absolute_url(),follow=True)
self.assertEquals(r.status_code,200)
self.assertTrue(tag.name in r.content)
self.assertTrue(markdown.markdown(post.text) in r.content)