<s> """<STR_LIT>""" <EOL> import mock <EOL> from flask import Blueprint , url_for <EOL> from flask . views import MethodView <EOL> from flask_via . routers import default <EOL> from tests import ViaTestCase <EOL> class TestFlaskFunctionalRouter ( ViaTestCase ) : <EOL> def setUp ( self ) : <EOL> self . view = mock . MagicMock ( <EOL> __name__ = '<STR_LIT:foo>' , <EOL> methods = [ '<STR_LIT:GET>' , ] , <EOL> return_value = '<STR_LIT:foo>' ) <EOL> def test_add_to_app ( self ) : <EOL> route = default . Functional ( '<STR_LIT:/>' , self . view , endpoint = '<STR_LIT:foo>' ) <EOL> route . add_to_app ( self . app ) <EOL> self . assertEqual ( url_for ( '<STR_LIT:foo>' ) , '<STR_LIT:/>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT:/>' ) . data , b'<STR_LIT:foo>' ) <EOL> def test_url_prefix ( self ) : <EOL> route = default . Functional ( '<STR_LIT:/>' , self . view , endpoint = '<STR_LIT:foo>' ) <EOL> route . add_to_app ( self . app , url_prefix = '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT:foo>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT>' ) . data , b'<STR_LIT:foo>' ) <EOL> def test_endpoint_prefix ( self ) : <EOL> route = default . Functional ( '<STR_LIT:/>' , self . view , endpoint = '<STR_LIT:foo>' ) <EOL> route . add_to_app ( self . app , endpoint = '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT:/>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT:/>' ) . data , b'<STR_LIT:foo>' ) <EOL> def test_default_endpoint_name ( self ) : <EOL> route = default . Functional ( '<STR_LIT:/>' , self . view ) <EOL> route . add_to_app ( self . app , endpoint = '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT:/>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT:/>' ) . data , b'<STR_LIT:foo>' ) <EOL> class TestFlaskPluggableRouter ( ViaTestCase ) : <EOL> def setUp ( self ) : <EOL> class View ( MethodView ) : <EOL> def get ( self ) : <EOL> return '<STR_LIT:foo>' <EOL> self . View = View <EOL> def test_add_to_app ( self ) : <EOL> route = default . Pluggable ( '<STR_LIT:/>' , self . View , '<STR_LIT:foo>' ) <EOL> route . add_to_app ( self . app ) <EOL> self . assertEqual ( url_for ( '<STR_LIT:foo>' ) , '<STR_LIT:/>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT:/>' ) . data , b'<STR_LIT:foo>' ) <EOL> def test_url_prefix ( self ) : <EOL> route = default . Pluggable ( '<STR_LIT:/>' , self . View , '<STR_LIT:foo>' ) <EOL> route . add_to_app ( self . app , url_prefix = '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT:foo>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT>' ) . data , b'<STR_LIT:foo>' ) <EOL> def test_endpoint_prefix ( self ) : <EOL> route = default . Pluggable ( '<STR_LIT:/>' , self . View , endpoint = '<STR_LIT:foo>' ) <EOL> route . add_to_app ( self . app , endpoint = '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT:/>' ) <EOL> self . assertEqual ( self . client . get ( '<STR_LIT:/>' ) . data , b'<STR_LIT:foo>' ) <EOL> class TestBlueprintRouter ( ViaTestCase ) : <EOL> def test_routes_module_path ( self ) : <EOL> route = default . Blueprint ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> self . assertEqual ( route . routes_module , '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_bluepint_creates_blurprint ( self , _get_root_path ) : <EOL> route = default . Blueprint ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> self . assertIsInstance ( route . blueprint ( ) , Blueprint ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_bluepint_returns_blurprint ( self , _get_root_path ) : <EOL> blueprint = Blueprint ( '<STR_LIT:foo>' , __name__ ) <EOL> route = default . Blueprint ( blueprint ) <EOL> self . assertIsInstance ( route . blueprint ( ) , Blueprint ) <EOL> self . assertEqual ( route . blueprint ( ) , blueprint ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_url_prefix ( self , _get_root_path ) : <EOL> route = default . Blueprint ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> blueprint = route . blueprint ( url_prefix = '<STR_LIT>' ) <EOL> self . assertEqual ( blueprint . url_prefix , '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_endpoint_prefix ( self , _get_root_path ) : <EOL> route = default . Blueprint ( '<STR_LIT:bar>' , '<STR_LIT>' ) <EOL> blueprint = route . blueprint ( endpoint = '<STR_LIT>' ) <EOL> self . assertEqual ( blueprint . name , '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_add_to_app ( self , _import_module ) : <EOL> foo = mock . MagicMock ( <EOL> __name__ = '<STR_LIT:foo>' , <EOL> methods = [ '<STR_LIT:GET>' , ] , <EOL> return_value = '<STR_LIT:foo>' ) <EOL> bar = mock . MagicMock ( <EOL> __name__ = '<STR_LIT:bar>' , <EOL> methods = [ '<STR_LIT:GET>' , ] , <EOL> return_value = '<STR_LIT:bar>' ) <EOL> routes = [ <EOL> default . Functional ( '<STR_LIT>' , foo , '<STR_LIT:foo>' ) , <EOL> default . Functional ( '<STR_LIT>' , bar , '<STR_LIT:bar>' ) , <EOL> ] <EOL> _import_module . side_effect = [ <EOL> mock . MagicMock ( routes = routes ) , <EOL> ] <EOL> route = default . Blueprint ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> with mock . patch ( '<STR_LIT>' ) : <EOL> route . add_to_app ( self . app ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) </s>
