<s> from __future__ import unicode_literals <EOL> from flask import url_for , Blueprint <EOL> import flask_restplus as restplus <EOL> from . import TestCase <EOL> class APITestCase ( TestCase ) : <EOL> def test_root_endpoint ( self ) : <EOL> api = restplus . Api ( self . app , version = '<STR_LIT:1.0>' ) <EOL> with self . context ( ) : <EOL> url = url_for ( '<STR_LIT:root>' ) <EOL> self . assertEqual ( url , '<STR_LIT:/>' ) <EOL> self . assertEqual ( api . base_url , '<STR_LIT>' ) <EOL> def test_root_endpoint_lazy ( self ) : <EOL> api = restplus . Api ( version = '<STR_LIT:1.0>' ) <EOL> api . init_app ( self . app ) <EOL> with self . context ( ) : <EOL> url = url_for ( '<STR_LIT:root>' ) <EOL> self . assertEqual ( url , '<STR_LIT:/>' ) <EOL> self . assertEqual ( api . base_url , '<STR_LIT>' ) <EOL> def test_root_endpoint_with_blueprint ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , url_prefix = '<STR_LIT>' ) <EOL> api = restplus . Api ( blueprint , version = '<STR_LIT:1.0>' ) <EOL> self . app . register_blueprint ( blueprint ) <EOL> with self . context ( ) : <EOL> url = url_for ( '<STR_LIT>' ) <EOL> self . assertEqual ( url , '<STR_LIT>' ) <EOL> self . assertEqual ( api . base_url , '<STR_LIT>' ) <EOL> def test_root_endpoint_with_blueprint_with_subdomain ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , subdomain = '<STR_LIT>' , url_prefix = '<STR_LIT>' ) <EOL> api = restplus . Api ( blueprint , version = '<STR_LIT:1.0>' ) <EOL> self . app . register_blueprint ( blueprint ) <EOL> with self . context ( ) : <EOL> url = url_for ( '<STR_LIT>' ) <EOL> self . assertEqual ( url , '<STR_LIT>' ) <EOL> self . assertEqual ( api . base_url , '<STR_LIT>' ) <EOL> def test_parser ( self ) : <EOL> api = restplus . Api ( ) <EOL> self . assertIsInstance ( api . parser ( ) , restplus . reqparse . RequestParser ) <EOL> def test_doc_decorator ( self ) : <EOL> api = restplus . Api ( self . app , prefix = '<STR_LIT>' , version = '<STR_LIT:1.0>' ) <EOL> params = { '<STR_LIT:q>' : { '<STR_LIT:description>' : '<STR_LIT>' } } <EOL> @ api . doc ( params = params ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> self . assertTrue ( hasattr ( TestResource , '<STR_LIT>' ) ) <EOL> self . assertEqual ( TestResource . __apidoc__ , { '<STR_LIT>' : params } ) <EOL> def test_doc_with_inheritance ( self ) : <EOL> api = restplus . Api ( self . app , prefix = '<STR_LIT>' , version = '<STR_LIT:1.0>' ) <EOL> base_params = { '<STR_LIT:q>' : { '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT:string>' , '<STR_LIT>' : '<STR_LIT>' } } <EOL> child_params = { '<STR_LIT:q>' : { '<STR_LIT:description>' : '<STR_LIT>' } , '<STR_LIT>' : { '<STR_LIT:description>' : '<STR_LIT>' } } <EOL> @ api . doc ( params = base_params ) <EOL> class BaseResource ( restplus . Resource ) : <EOL> pass <EOL> @ api . doc ( params = child_params ) <EOL> class TestResource ( BaseResource ) : <EOL> pass <EOL> self . assertEqual ( TestResource . __apidoc__ , { '<STR_LIT>' : { <EOL> '<STR_LIT:q>' : { <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT:string>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> '<STR_LIT>' : { '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> } } ) <EOL> def test_specs_endpoint_not_added ( self ) : <EOL> api = restplus . Api ( ) <EOL> api . init_app ( self . app , add_specs = False ) <EOL> self . assertNotIn ( '<STR_LIT>' , api . endpoints ) <EOL> self . assertNotIn ( '<STR_LIT>' , self . app . view_functions ) <EOL> def test_specs_endpoint_not_found_if_not_added ( self ) : <EOL> api = restplus . Api ( ) <EOL> api . init_app ( self . app , add_specs = False ) <EOL> with self . app . test_client ( ) as client : <EOL> resp = client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT> ) <EOL> def test_default_endpoint ( self ) : <EOL> api = restplus . Api ( self . app ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_default_endpoint_lazy ( self ) : <EOL> api = restplus . Api ( ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> api . init_app ( self . app ) <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_default_endpoint_with_blueprint ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , url_prefix = '<STR_LIT>' ) <EOL> api = restplus . Api ( blueprint ) <EOL> self . app . register_blueprint ( blueprint ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_default_endpoint_with_blueprint_with_subdomain ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , subdomain = '<STR_LIT>' , url_prefix = '<STR_LIT>' ) <EOL> api = restplus . Api ( blueprint ) <EOL> self . app . register_blueprint ( blueprint ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_default_endpoint_for_namespace ( self ) : <EOL> api = restplus . Api ( self . app ) <EOL> ns = api . namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_default_endpoint_lazy_for_namespace ( self ) : <EOL> api = restplus . Api ( ) <EOL> ns = api . namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> api . init_app ( self . app ) <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_default_endpoint_for_namespace_with_blueprint ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , url_prefix = '<STR_LIT>' ) <EOL> api = restplus . Api ( blueprint ) <EOL> ns = api . namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> self . app . register_blueprint ( blueprint ) <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_multiple_default_endpoint ( self ) : <EOL> api = restplus . Api ( self . app ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_multiple_default_endpoint_lazy ( self ) : <EOL> api = restplus . Api ( ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> @ api . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> api . init_app ( self . app ) <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_multiple_default_endpoint_for_namespace ( self ) : <EOL> api = restplus . Api ( self . app ) <EOL> ns = api . namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_multiple_default_endpoint_lazy_for_namespace ( self ) : <EOL> api = restplus . Api ( ) <EOL> ns = api . namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> api . init_app ( self . app ) <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_multiple_default_endpoint_for_namespace_with_blueprint ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' , __name__ , url_prefix = '<STR_LIT>' ) <EOL> api = restplus . Api ( blueprint ) <EOL> ns = api . namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> @ ns . route ( '<STR_LIT>' ) <EOL> class TestResource ( restplus . Resource ) : <EOL> pass <EOL> self . app . register_blueprint ( blueprint ) <EOL> with self . context ( ) : <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( url_for ( '<STR_LIT>' ) , '<STR_LIT>' ) </s>
