async def test_url_for_scheme(app: Quart) -> None: async with app.test_request_context("/"): with pytest.raises(ValueError): url_for("index", _scheme="https") assert url_for("index", _scheme="https", _external=True) == "https://localhost/" assert (url_for("resource", id=5, _scheme="https", _external=True) == "https://localhost/resource/5")
async def test_url_for_scheme(app: Quart) -> None: async with app.test_request_context('GET', '/'): with pytest.raises(ValueError): url_for('index', _scheme='https') assert url_for('index', _scheme='https', _external=True) == 'https://localhost/' assert url_for( 'resource', id=5, _scheme='https', _external=True, ) == 'https://localhost/resource/5'
async def test_url_for_blueprint_relative(app: Quart) -> None: blueprint = Blueprint("blueprint", __name__) @blueprint.route("/") def index() -> str: return "" app.register_blueprint(blueprint, url_prefix="/blue") async with app.test_request_context("/blue/"): assert url_for(".index") == "/blue/" assert url_for("index") == "/"
async def test_url_for_blueprint_relative(app: Quart) -> None: blueprint = Blueprint('blueprint', __name__) @blueprint.route('/') def index() -> str: return '' app.register_blueprint(blueprint, url_prefix='/blue') async with app.test_request_context('/blue/'): assert url_for('.index') == '/blue/' assert url_for('index') == '/'
async def test_url_for_external(app: Quart) -> None: async with app.test_request_context("/"): assert url_for("index") == "/" assert url_for("index", _external=True) == "http://localhost/" assert url_for("resource", id=5, _external=True) == "http://localhost/resource/5" assert url_for("resource", id=5, _external=False) == "/resource/5" async with app.app_context(): assert url_for("index") == "http://localhost/" assert url_for("index", _external=False) == "/"
async def test_url_for_external(app: Quart) -> None: async with app.test_request_context('/'): assert url_for('index') == '/' assert url_for('index', _external=True) == 'http://localhost/' assert url_for('resource', id=5, _external=True) == 'http://localhost/resource/5' assert url_for('resource', id=5, _external=False) == '/resource/5' async with app.app_context(): assert url_for('index') == 'http://localhost/' assert url_for('index', _external=False) == '/'
async def test_url_for_host_matching(host_matched_app: Quart) -> None: async with host_matched_app.app_context(): assert url_for("index", _external=True) == "http:///" assert url_for("host", _external=True) == "http://quart.com/"
async def test_url_for(app: Quart) -> None: async with app.test_request_context("/"): assert url_for("index") == "/" assert url_for("index_post", _method="POST") == "/post" assert url_for("resource", id=5) == "/resource/5"
async def test_url_for_anchor(app: Quart) -> None: async with app.test_request_context("/"): assert url_for("index", _anchor="&foo") == "/#%26foo" assert url_for("resource", id=5, _anchor="&foo") == "/resource/5#%26foo"
async def test_url_for_host_matching(host_matched_app: Quart) -> None: async with host_matched_app.app_context(): assert url_for('index') == 'http://localhost/' assert url_for('host') == 'http://quart.com/'
async def test_url_for(app: Quart) -> None: async with app.test_request_context('/'): assert url_for('index') == '/' assert url_for('index_post', _method='POST') == '/post' assert url_for('resource', id=5) == '/resource/5'
async def test_url_for_anchor(app: Quart) -> None: async with app.test_request_context('/'): assert url_for('index', _anchor='&foo') == '/#%26foo' assert url_for('resource', id=5, _anchor='&foo') == '/resource/5#%26foo'
async def test_url_for_host_matching(host_matched_app: Quart) -> None: async with host_matched_app.app_context(): assert url_for("index") == "http://localhost/" assert url_for("host") == "http://quart.com/"
def test_url_for_anchor(app: Quart) -> None: with app.app_context(): assert url_for('index', _anchor='&foo') == '/#%26foo' assert url_for('resource', id=5, _anchor='&foo') == '/resource/5#%26foo'
def test_url_for_external(app: Quart) -> None: with app.app_context(): assert url_for('index', _external=True) == 'http://localhost/' assert url_for('resource', id=5, _external=True) == 'http://localhost/resource/5'
def test_url_for(app: Quart) -> None: with app.app_context(): assert url_for('index') == '/' assert url_for('index_post', _method='POST') == '/post' assert url_for('resource', id=5) == '/resource/5'