<s> import bottle <EOL> from tools import ServerTestBase <EOL> from bottle import response <EOL> class TestAppMounting ( ServerTestBase ) : <EOL> def setUp ( self ) : <EOL> ServerTestBase . setUp ( self ) <EOL> self . subapp = bottle . Bottle ( ) <EOL> @ self . subapp . route ( '<STR_LIT>' ) <EOL> @ self . subapp . route ( '<STR_LIT:/>' ) <EOL> @ self . subapp . route ( '<STR_LIT>' ) <EOL> def test ( test = '<STR_LIT:foo>' ) : <EOL> return test <EOL> def test_mount_order_bug581 ( self ) : <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> self . app . route ( '<STR_LIT>' , callback = lambda test : test ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> def test_mount ( self ) : <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> self . assertStatus ( <NUM_LIT> , '<STR_LIT:/>' ) <EOL> self . assertStatus ( <NUM_LIT> , '<STR_LIT>' ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:bar>' , '<STR_LIT>' ) <EOL> def test_mount_meta ( self ) : <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> self . assertEqual ( <EOL> self . subapp . config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> self . subapp . config [ '<STR_LIT>' ] , self . app ) <EOL> def test_no_slash_prefix ( self ) : <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> self . assertStatus ( <NUM_LIT> , '<STR_LIT:/>' ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:bar>' , '<STR_LIT>' ) <EOL> def test_mount_no_plugins ( self ) : <EOL> def plugin ( func ) : <EOL> def wrapper ( * a , ** ka ) : <EOL> return '<STR_LIT>' <EOL> return wrapper <EOL> self . app . install ( plugin ) <EOL> self . app . route ( '<STR_LIT>' , callback = lambda : '<STR_LIT>' ) <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> self . assertBody ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> def test_mount_wsgi ( self ) : <EOL> status = { } <EOL> def app ( environ , start_response ) : <EOL> start_response ( '<STR_LIT>' , [ ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> return '<STR_LIT>' + environ [ '<STR_LIT>' ] <EOL> self . app . mount ( '<STR_LIT>' , app ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertHeader ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_mount_cookie ( self ) : <EOL> @ self . subapp . route ( '<STR_LIT>' ) <EOL> def test_cookie ( ) : <EOL> response . set_cookie ( '<STR_LIT:a>' , '<STR_LIT:a>' ) <EOL> response . set_cookie ( '<STR_LIT:b>' , '<STR_LIT:b>' ) <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> c = self . urlopen ( '<STR_LIT>' ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' ] , list ( sorted ( c . split ( '<STR_LIT:U+002CU+0020>' ) ) ) ) <EOL> def test_mount_wsgi_ctype_bug ( self ) : <EOL> status = { } <EOL> def app ( environ , start_response ) : <EOL> start_response ( '<STR_LIT>' , [ ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) ] ) <EOL> return '<STR_LIT>' + environ [ '<STR_LIT>' ] <EOL> self . app . mount ( '<STR_LIT>' , app ) <EOL> self . assertHeader ( '<STR_LIT:Content-Type>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_mount_json_bug ( self ) : <EOL> @ self . subapp . route ( '<STR_LIT>' ) <EOL> def test_cookie ( ) : <EOL> return { '<STR_LIT:a>' : <NUM_LIT:5> } <EOL> self . app . mount ( '<STR_LIT>' , self . subapp ) <EOL> self . assertHeader ( '<STR_LIT:Content-Type>' , '<STR_LIT:application/json>' , '<STR_LIT>' ) <EOL> class TestAppMerging ( ServerTestBase ) : <EOL> def setUp ( self ) : <EOL> ServerTestBase . setUp ( self ) <EOL> self . subapp = bottle . Bottle ( ) <EOL> @ self . subapp . route ( '<STR_LIT:/>' ) <EOL> @ self . subapp . route ( '<STR_LIT>' ) <EOL> def test ( test = '<STR_LIT:foo>' ) : <EOL> return test <EOL> def test_merge ( self ) : <EOL> self . app . merge ( self . subapp ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT:/>' ) <EOL> self . assertBody ( '<STR_LIT:foo>' , '<STR_LIT:/>' ) <EOL> self . assertStatus ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> self . assertBody ( '<STR_LIT:bar>' , '<STR_LIT>' ) </s>
