本文整理汇总了Python中wsgiservice.get_app函数的典型用法代码示例。如果您正苦于以下问题:Python get_app函数的具体用法?Python get_app怎么用?Python get_app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_app函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_modified_generate
def test_modified_generate():
"""Resource generates a good Last-Modified response header."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4?id=myid')
res = app._handle_request(req)
print res._headers
assert res._headers['Last-Modified'] == 'Fri, 01 May 2009 14:30:00 GMT'
示例2: test_etag_generate_json_ext
def test_etag_generate_json_ext():
"""ETags are calculated by adding the extension to the custom etag."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4.json?id=myid')
res = app._handle_request(req)
print res
assert res._headers['ETag'] == '"myid_json"'
示例3: test_exception_json
def test_exception_json():
"""An exception is serialized as a dictionary in JSON."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res5?throw=1', {'HTTP_ACCEPT': 'application/json'})
res = app._handle_request(req)
print res
assert res.status == '500 Internal Server Error'
assert res.body == '{"error": "Some random exception."}'
示例4: test_res6_default
def test_res6_default():
"""Resource6 works normally for keys which exist on the resource."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res6/uid')
res = app._handle_request(req)
print res
assert res.status == '200 OK'
assert res.body == '<response>works</response>'
示例5: test_etag_if_match_not_set
def test_etag_if_match_not_set():
"""A GET request without an If-Match header passes."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4?id=myid')
res = app._handle_request(req)
print res
assert res._headers['ETag'] == '"myid_xml"'
assert res.status == '200 OK'
示例6: test_etag_if_match_true
def test_etag_if_match_true():
"""A GET request with a matching If-Match passes."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4?id=myid', {'HTTP_IF_MATCH': '"myid_xml"'})
res = app._handle_request(req)
print res
assert res._headers['ETag'] == '"myid_xml"'
assert res.status == '200 OK'
示例7: test_with_expires
def test_with_expires():
"""expires decorator correctly sets the Cache-Control header."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res3')
res = app._handle_request(req)
print str(res)
print res._headers
assert res._headers['Cache-Control'] == 'max-age=86400'
示例8: test_notfound_xml
def test_notfound_xml():
"""Requests that cause a NOT_FOUND exception return 404."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res6/foo')
res = app._handle_request(req)
print res
assert res.status == '404 Not Found'
assert res.body == '<response><error>Not Found</error></response>'
示例9: test_with_expires_calculations
def test_with_expires_calculations():
"""expires decorator correctly sets the Expires header."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4')
res = app._handle_request(req)
print res._headers
assert res._headers['Cache-Control'] == 'max-age=138'
assert res._headers['Expires'] == 'Mon, 20 Apr 2009 17:55:45 GMT'
示例10: test_app_handle_404
def test_app_handle_404():
"""Application returns a 404 status code if no resource is found."""
app = wsgiservice.get_app(globals())
req = Request.blank('/foo')
res = app._handle_request(req)
print res
assert res.status == '404 Not Found'
assert res.body == ''
示例11: test_app_handle_options
def test_app_handle_options():
"""Resource provides a good default for the OPTIONS method."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res2', {'REQUEST_METHOD': 'OPTIONS'})
res = app._handle_request(req)
print res
assert res.status == '200 OK'
assert res._headers['Allow'] == 'OPTIONS, POST, PUT'
示例12: test_etag_if_match_false
def test_etag_if_match_false():
"""A GET request with a non-matching If-Match returns 412."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4?id=myid',
{'HTTP_IF_MATCH': '"otherid"'})
res = app._handle_request(req)
print res
assert res._headers['ETag'] == '"myid_xml"'
assert res.status == '412 Precondition Failed'
示例13: test_with_expires_calculations_double_wrapped
def test_with_expires_calculations_double_wrapped():
"""Wrapped expires decorators work by just using the last one."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res4', {'REQUEST_METHOD': 'POST'})
res = app._handle_request(req)
print str(res)
print res._headers
assert res._headers['Cache-Control'] == 'max-age=138'
assert res._headers['Expires'] == 'Mon, 20 Apr 2009 17:55:45 GMT'
示例14: test_with_expires_vary
def test_with_expires_vary():
"""expires decorator can set the Vary header."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res6/uid')
res = app._handle_request(req)
print str(res)
print res._headers
assert res._headers['Cache-Control'] == 'max-age=86400'
assert res._headers['Vary'] == 'Authorization, Accept'
示例15: test_verify_content_md5_valid
def test_verify_content_md5_valid():
"""A request with a body that matches Content-MD5 passes."""
app = wsgiservice.get_app(globals())
req = Request.blank('/res1/theid', {
'HTTP_CONTENT_MD5': '89d5739baabbbe65be35cbe61c88e06d',
'wsgi.input': StringIO.StringIO('Foobar')})
res = app._handle_request(req)
print res
assert res.status == '200 OK'