本文整理汇总了Python中pyramid.testing.DummyRequest.POST["create_page"]方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.POST["create_page"]方法的具体用法?Python DummyRequest.POST["create_page"]怎么用?Python DummyRequest.POST["create_page"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.POST["create_page"]方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_confirmation_page_data_not_in_POST_or_session
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["create_page"] [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"
示例2: test_POST_page_data_for_pattern_input
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["create_page"] [as 别名]
def test_POST_page_data_for_pattern_input(self):
"""
This method will test the ability of the create view to access the correct page data from the POST. The
expected result of this test is for the correct page data to be available for the 'pattern input' page.
"""
# Set up the request for testing the 'create pattern' page on POST
post_request = DummyRequest(route='/create')
post_request.POST["create_page"] = "pattern_input"
post_response = create_view(post_request)
# Assert that the response contains the correct page data
assert post_response["title"] == "Create Pattern"
assert post_response["page"] == "patternpage"
示例3: test_confirmation_viewing_date_formatting_failure
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["create_page"] [as 别名]
def test_confirmation_viewing_date_formatting_failure(self):
"""
This method will test the ability of the create view to access the correct page data fro the session or
POST. The expected result of this test is for the create view to raise an exception because the viewing date
is the wrong format.
"""
# Set up the request for testing the 'confirmation' page with a wrongly formatted viewing date
request = DummyRequest(route='/create')
request.POST["create_page"] = "confirmation"
request.POST["viewing_date"] = datetime.datetime.today()
# Assert that an exception is thrown because the viewing date is of the wrong format
try:
response = create_view(request)
except ArgumentError as e:
assert e.args[0] == "Viewing date incorrectly formatted"
示例4: test_POST_page_data_for_scheduling
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["create_page"] [as 别名]
def test_POST_page_data_for_scheduling(self):
"""
This method will test the ability of the create view to access the correct page data from the POST. The
expected result of this test is for the correct page data to be available for the 'scheduling' page.
"""
# Set up the request for testing the 'scheduling' page on POST
post_request = DummyRequest(route='/create')
post_request.POST["create_page"] = "scheduler"
post_response = create_view(post_request)
# Assert that the response contains the correct page data
assert post_response["title"] == "Scheduler"
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)
示例5: test_POST_page_data_for_confirmation
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import POST["create_page"] [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)