本文整理汇总了Python中django.http.request.HttpRequest.POST["item_text"]方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.POST["item_text"]方法的具体用法?Python HttpRequest.POST["item_text"]怎么用?Python HttpRequest.POST["item_text"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.request.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.POST["item_text"]方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_home_page_redirects_after_POST
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST["item_text"] [as 别名]
def test_home_page_redirects_after_POST(self):
request = HttpRequest()
request.method = "POST"
request.POST["item_text"] = 'A new list item'
response = home_page(request)
self.assertEqual(response.status_code, 302)
self.assertEqual(response['location'], '/')
示例2: test_home_page_can_save_a_POST_requeste
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST["item_text"] [as 别名]
def test_home_page_can_save_a_POST_requeste(self):
request = HttpRequest()
request.method = "POST"
request.POST["item_text"] = 'A new list item'
response = home_page(request)
self.assertEqual(Item.objects.count(), 1)
newItem = Item.objects.first()
self.assertEqual(newItem.text, 'A new list item')
示例3: test_user_can_post
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST["item_text"] [as 别名]
def test_user_can_post(self):
request = HttpRequest()
request.method = "POST"
request.POST["item_text"] = "A new text item"
# Make a request
response = views.index(request)
# Count the number of objects in DB
self.assertEqual(Item.objects.all().count(), 1)
new_item = Item.objects.all()[0]
self.assertEqual(
new_item.item,
"A new text item",
"Expected {text} but got {text2}".format(text="A new text item", text2=new_item.item),
)
self.assertIn("A new text item", response.content.decode())
expected_html = render_to_string("chronassist/base.html", {"new_item_text": request.POST["item_text"]})
self.assertEqual(response.content.decode(), expected_html)