<s> from __future__ import absolute_import , unicode_literals <EOL> from werkzeug . routing import Map , Rule <EOL> from mongorest . testcase import TestCase <EOL> from mongorest . wrappers import Response <EOL> from mongorest . wsgi import WSGIWrapper , WSGIDispatcher <EOL> class TestWSGIWrapper ( TestCase ) : <EOL> def test_wsgi_wrapper_sets_empty_endpoint ( self ) : <EOL> self . assertIsNotNone ( WSGIWrapper . endpoint ) <EOL> def test_wsgi_wrapper_sets_empty_urls_list ( self ) : <EOL> self . assertIsInstance ( WSGIWrapper . rules , list ) <EOL> def test_wsgi_wrapper_sets_empty_url_map ( self ) : <EOL> self . assertIsInstance ( WSGIWrapper . url_map , Map ) <EOL> def test_wsgi_wrapper_executes_correct_view_if_url_exists_on_map ( self ) : <EOL> class WSGIWrapperTest ( WSGIWrapper ) : <EOL> url_map = Map ( [ Rule ( '<STR_LIT:/>' , methods = [ '<STR_LIT:GET>' ] , endpoint = '<STR_LIT:test>' ) ] ) <EOL> def test ( self , request ) : <EOL> return Response ( status = <NUM_LIT> ) <EOL> app = WSGIDispatcher ( resources = [ WSGIWrapperTest ] ) <EOL> response = self . client ( app , Response ) . get ( '<STR_LIT:/>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_wsgi_wrapper_returns_not_found_if_no_url_is_found_with_trailing_slash ( self ) : <EOL> class WSGIWrapperTest ( WSGIWrapper ) : <EOL> url_map = Map ( [ Rule ( '<STR_LIT:/>' , methods = [ '<STR_LIT:GET>' ] , endpoint = '<STR_LIT:test>' ) ] ) <EOL> def test ( self , request ) : <EOL> return Response ( status = <NUM_LIT> ) <EOL> app = WSGIDispatcher ( resources = [ WSGIWrapperTest ] ) <EOL> response = self . client ( app , Response ) . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_wsgi_wrapper_returns_not_found_if_no_url_is_found_without_trailing_slash ( self ) : <EOL> class WSGIWrapperTest ( WSGIWrapper ) : <EOL> url_map = Map ( [ Rule ( '<STR_LIT:/>' , methods = [ '<STR_LIT:GET>' ] , endpoint = '<STR_LIT:test>' ) ] ) <EOL> def test ( self , request ) : <EOL> return Response ( status = <NUM_LIT> ) <EOL> app = WSGIDispatcher ( resources = [ WSGIWrapperTest ] ) <EOL> response = self . client ( app , Response ) . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_wsgi_wrapper_redirects_to_correct_url_if_30x_status_and_follow_redirects ( self ) : <EOL> class WSGIWrapperTest ( WSGIWrapper ) : <EOL> url_map = Map ( [ Rule ( '<STR_LIT>' , methods = [ '<STR_LIT:GET>' ] , endpoint = '<STR_LIT:test>' ) ] ) <EOL> def test ( self , request ) : <EOL> return Response ( status = <NUM_LIT> ) <EOL> app = WSGIDispatcher ( resources = [ WSGIWrapperTest ] ) <EOL> response = self . client ( app , Response ) . get ( '<STR_LIT>' , follow_redirects = True ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) </s>
