当前位置: 首页>>代码示例>>Python>>正文


Python HttpRequest.POST["item_text"]方法代码示例

本文整理汇总了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'], '/')
开发者ID:tobiaszgithub,项目名称:test-driven-development-with-python,代码行数:11,代码来源:tests.py

示例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')
开发者ID:tobiaszgithub,项目名称:test-driven-development-with-python,代码行数:12,代码来源:tests.py

示例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)
开发者ID:anshulthakur,项目名称:scheduler,代码行数:22,代码来源:test_unit.py


注:本文中的django.http.request.HttpRequest.POST["item_text"]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。