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


Python DummyRequest.POST["viewing_hour"]方法代码示例

本文整理汇总了Python中pyramid.testing.DummyRequest.POST["viewing_hour"]方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.POST["viewing_hour"]方法的具体用法?Python DummyRequest.POST["viewing_hour"]怎么用?Python DummyRequest.POST["viewing_hour"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.testing.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.POST["viewing_hour"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_confirmation_page_data_not_in_POST_or_session

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["viewing_hour"] [as 别名]
    def test_confirmation_page_data_not_in_POST_or_session(self):
        """
        This method will test the ability of the create view to access the correct page data from the session and/or
        POST. The expected result of this test is for the create view to raise an exception because the viewing
        information has not been passed to the confirmation page.
        """
        # Set up the request for testing the 'confirmation' page without viewing date
        request = DummyRequest(route='/create')
        request.POST["create_page"] = "confirmation"

        # Assert that an exception is thrown because a viewing date has not been stored in session or POST
        try:
            response = create_view(request)
        except ArgumentError as e:
            assert e.args[0] == "Viewing date was not submitted"

        # Set up the request for testing the 'confirmation' page without viewing hour
        request.POST["viewing_date"] = datetime.datetime(2014, 7, 21, 12, 30, 3).strftime("%d/%m/%Y")

        # Assert that an exception is thrown because a viewing hour has not been stored in session or POST
        try:
            response = create_view(request)
        except ArgumentError as e:
            assert e.args[0] == "Viewing hour was not submitted"

        # Set up the request for testing the 'confirmation' page without viewing slot
        request.POST["viewing_hour"] = datetime.datetime.now().hour

        # Assert that an exception is thrown because a viewing slot has not been stored in session or POST
        try:
            response = create_view(request)
        except ArgumentError as e:
            assert e.args[0] == "Viewing slot was not submitted"
开发者ID:CO600GOL,项目名称:Game_of_life,代码行数:35,代码来源:test_create.py

示例2: test_POST_page_data_for_confirmation

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["viewing_hour"] [as 别名]
    def test_POST_page_data_for_confirmation(self):
        """
        This method will test the ability of the create view to access the correct page data from POST. The
        expected result of this test is for the correct page data to be available for the 'confirmation' page.
        """
        # Set up the request for testing the 'confirmation' page on POST
        post_request = DummyRequest(route='/create')
        post_request.POST["create_page"] = "confirmation"
        post_request.POST["viewing_date"] = datetime.datetime.today().strftime("%d/%m/%Y")
        post_request.POST["viewing_hour"] = datetime.datetime.now().hour
        post_request.POST["viewing_slot"] = 25 # hard-coded because it must be a multiple of 5

        post_response = create_view(post_request)

        # Assert that the response contains the correct page data
        assert post_response["title"] == "Confirmation"
        assert post_response["page"] == "patternpage"
        assert isinstance(post_response["viewing_date"], str)
        assert isinstance(post_response["viewing_hour"], int)
        assert isinstance(post_response["viewing_slot"], int)
        assert isinstance(post_response["display_address"], str)
开发者ID:CO600GOL,项目名称:Game_of_life,代码行数:23,代码来源:test_create.py


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