<s> import mox <EOL> import StringIO <EOL> import time <EOL> from datetime import timedelta <EOL> from webob import Request <EOL> import wsgiservice <EOL> import wsgiservice . application <EOL> import wsgiservice . exceptions <EOL> def test_getapp ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> print app <EOL> print app . _resources <EOL> assert isinstance ( app , wsgiservice . application . Application ) <EOL> assert len ( app . _resources ) == <NUM_LIT:7> <EOL> resources = ( Resource1 , Resource2 , Resource3 , Resource4 , Resource5 , <EOL> Resource6 ) <EOL> assert app . _resources [ <NUM_LIT:0> ] in resources <EOL> assert app . _resources [ <NUM_LIT:1> ] in resources <EOL> assert app . _resources [ <NUM_LIT:2> ] in resources <EOL> assert app . _resources [ <NUM_LIT:3> ] in resources <EOL> assert app . _resources [ <NUM_LIT:4> ] in resources <EOL> assert app . _resources [ <NUM_LIT:5> ] in resources <EOL> def test_app_handle_404 ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' '<STR_LIT>' <EOL> assert res . headers [ '<STR_LIT:Content-Type>' ] == '<STR_LIT>' <EOL> def test_app_handle_method_not_allowed ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:GET>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_app_handle_method_not_known ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_app_handle_response_201_abs ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . location == '<STR_LIT>' <EOL> def test_app_handle_response_201_rel ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . location == '<STR_LIT>' <EOL> def test_app_handle_response_201_ext ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . location == '<STR_LIT>' <EOL> def test_app_handle_options ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_app_get_simple ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> body = '<STR_LIT>' <EOL> req = Request . blank ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : str ( len ( body ) ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : StringIO . StringIO ( body ) } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . body == "<STR_LIT>" "<STR_LIT>" <EOL> def test_app_head_revert_to_get_simple ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> body = '<STR_LIT>' <EOL> req = Request . blank ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : str ( len ( body ) ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : StringIO . StringIO ( body ) } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> def test_app_post_simple ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> body = '<STR_LIT>' <EOL> req = Request . blank ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT:POST>' , '<STR_LIT>' : str ( len ( body ) ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : StringIO . StringIO ( body ) } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == "<STR_LIT>" "<STR_LIT>" <EOL> def test_app_wsgi ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> env = Request . blank ( '<STR_LIT>' ) . environ <EOL> start_response = mox . MockAnything ( ) <EOL> start_response ( '<STR_LIT>' , [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> mox . Replay ( start_response ) <EOL> res = app ( env , start_response ) <EOL> print res <EOL> mox . Verify ( start_response ) <EOL> assert res == [ '<STR_LIT>' ] <EOL> def test_validation_method ( ) : <EOL> """<STR_LIT>""" <EOL> inst = Resource1 ( None , None , None ) <EOL> inst . validate_param ( inst . POST , '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> def test_validation_class ( ) : <EOL> """<STR_LIT>""" <EOL> inst = Resource1 ( None , None , None ) <EOL> inst . validate_param ( inst . GET , '<STR_LIT:id>' , '<STR_LIT>' ) <EOL> def test_validation_with_re_none_value ( ) : <EOL> """<STR_LIT>""" <EOL> inst = Resource1 ( None , None , None ) <EOL> try : <EOL> inst . validate_param ( inst . GET , '<STR_LIT:id>' , None ) <EOL> except wsgiservice . exceptions . ValidationException , e : <EOL> print e <EOL> assert str ( e ) == '<STR_LIT>' <EOL> else : <EOL> assert False , "<STR_LIT>" <EOL> def test_validation_with_re_mismatch ( ) : <EOL> """<STR_LIT>""" <EOL> inst = Resource1 ( None , None , None ) <EOL> try : <EOL> inst . validate_param ( inst . GET , '<STR_LIT:id>' , '<STR_LIT>' ) <EOL> except wsgiservice . exceptions . ValidationException , e : <EOL> print e <EOL> assert str ( e ) == '<STR_LIT>' <EOL> else : <EOL> assert False , "<STR_LIT>" <EOL> def test_validation_with_re_mismatch_toolong ( ) : <EOL> """<STR_LIT>""" <EOL> inst = Resource1 ( None , None , None ) <EOL> try : <EOL> inst . validate_param ( inst . GET , '<STR_LIT:id>' , '<STR_LIT>' ) <EOL> except wsgiservice . exceptions . ValidationException , e : <EOL> print e <EOL> assert str ( e ) == '<STR_LIT>' <EOL> else : <EOL> assert False , "<STR_LIT>" <EOL> def test_with_expires ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print str ( res ) <EOL> print res . _headers <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_with_expires_vary ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print str ( res ) <EOL> print res . _headers <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_with_expires_calculations ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res . _headers <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_with_expires_calculations_double_wrapped ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print str ( res ) <EOL> print res . _headers <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_etag_generate ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res . _headers <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_etag_generate_json ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:application/json>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_etag_generate_json_ext ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_etag_if_match_false ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_etag_if_match_true ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_etag_if_match_not_set ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_etag_if_none_match_get_true ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> assert '<STR_LIT:Content-Type>' not in res . headers <EOL> def test_etag_if_none_match_head_true ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_etag_if_none_match_post_true ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_etag_if_none_match_false ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_modified_generate ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res . _headers <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_if_modified_since_false ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_if_modified_since_true ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_if_unmodified_since_false ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_if_unmodified_since_false_head ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . body == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_if_unmodified_since_false_post ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> print res . status <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_if_unmodified_since_true ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . _headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert res . status == '<STR_LIT>' <EOL> def test_verify_content_md5_invalid ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : StringIO . StringIO ( '<STR_LIT>' ) } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> print res . status <EOL> print res . _headers <EOL> assert '<STR_LIT>' not in res . _headers <EOL> assert '<STR_LIT>' not in res . _headers <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' '<STR_LIT>' <EOL> def test_verify_content_md5_valid ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> req . body_file = StringIO . StringIO ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> def test_exception_json ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:application/json>' } ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> def test_exception_xml ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' '<STR_LIT>' <EOL> def test_res6_default ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> def test_notfound_xml ( ) : <EOL> """<STR_LIT>""" <EOL> app = wsgiservice . get_app ( globals ( ) ) <EOL> req = Request . blank ( '<STR_LIT>' ) <EOL> res = app . _handle_request ( req ) <EOL> print res <EOL> assert res . status == '<STR_LIT>' <EOL> assert res . body == '<STR_LIT>' <EOL> class AbstractResource ( wsgiservice . Resource ) : <EOL> """<STR_LIT>""" <EOL> class Resource1 ( wsgiservice . Resource ) : <EOL> _path = '<STR_LIT>' <EOL> _validations = { '<STR_LIT:id>' : { '<STR_LIT>' : '<STR_LIT>' } } <EOL> def GET ( self , id , foo ) : <EOL> return '<STR_LIT>' . format ( id , foo ) <EOL> def POST ( self , id , foo ) : <EOL> return '<STR_LIT>' . format ( id , foo ) <EOL> POST . _validations = { '<STR_LIT:foo>' : { '<STR_LIT>' : '<STR_LIT>' } } <EOL> class Resource2 ( wsgiservice . Resource ) : <EOL> _path = '<STR_LIT>' <EOL> def POST ( self ) : <EOL> wsgiservice . raise_201 ( self , '<STR_LIT>' ) <EOL> def PUT ( self ) : <EOL> wsgiservice . raise_201 ( self , '<STR_LIT:foo>' ) <EOL> class Resource3 ( AbstractResource ) : <EOL> _path = '<STR_LIT>' <EOL> @ wsgiservice . expires ( timedelta ( days = <NUM_LIT:1> ) ) <EOL> def GET ( self , id ) : <EOL> return "<STR_LIT>" . format ( id ) <EOL> class Resource4 ( wsgiservice . Resource ) : <EOL> _path = '<STR_LIT>' <EOL> @ wsgiservice . expires ( <NUM_LIT> , currtime = lambda : <NUM_LIT> ) <EOL> def GET ( self , id ) : <EOL> return "<STR_LIT>" . format ( id ) <EOL> @ wsgiservice . expires ( <NUM_LIT> , currtime = lambda : <NUM_LIT> ) <EOL> @ wsgiservice . expires ( <NUM_LIT> , currtime = lambda : <NUM_LIT> ) <EOL> def POST ( self , id ) : <EOL> return "<STR_LIT>" . format ( id ) <EOL> def get_etag ( self , id ) : <EOL> if id : <EOL> return id [ <NUM_LIT:0> ] + '<STR_LIT:">' + id [ <NUM_LIT:1> : ] <EOL> def get_last_modified ( self , id ) : <EOL> from webob import UTC <EOL> from datetime import datetime <EOL> return datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:30> , tzinfo = UTC ) <EOL> class Resource5 ( wsgiservice . Resource ) : <EOL> _path = '<STR_LIT>' <EOL> def GET ( self , throw ) : <EOL> if throw == '<STR_LIT:1>' : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> else : <EOL> return '<STR_LIT>' <EOL> class Resource6 ( wsgiservice . Resource ) : <EOL> class DummyException ( Exception ) : <EOL> pass <EOL> NOT_FOUND = ( KeyError , DummyException ) <EOL> _path = '<STR_LIT>' <EOL> items = { '<STR_LIT>' : '<STR_LIT>' } <EOL> @ wsgiservice . expires ( timedelta ( days = <NUM_LIT:1> ) , vary = [ '<STR_LIT>' ] ) <EOL> def GET ( self , id ) : <EOL> return self . items [ id ] <EOL> class NotAResource ( ) : <EOL> def __getattr__ ( self , name ) : <EOL> return name <EOL> not_a_class = NotAResource ( ) </s>
