forked from github.com/pypiserver
test fallback to pypi.python.org
This commit is contained in:
parent
7669d58114
commit
c24b490cfa
@ -9,6 +9,13 @@ from pypiserver import core
|
|||||||
import bottle
|
import bottle
|
||||||
bottle.debug(True)
|
bottle.debug(True)
|
||||||
|
|
||||||
|
fallback_app = bottle.Bottle()
|
||||||
|
|
||||||
|
|
||||||
|
@fallback_app.route("path#.*#")
|
||||||
|
def pypi_notfound(path):
|
||||||
|
return bottle.HTTPError(404)
|
||||||
|
|
||||||
|
|
||||||
def pytest_funcarg__root(request):
|
def pytest_funcarg__root(request):
|
||||||
|
|
||||||
@ -20,6 +27,7 @@ def pytest_funcarg__root(request):
|
|||||||
|
|
||||||
twill.add_wsgi_intercept("localhost", 8080, bottle.default_app)
|
twill.add_wsgi_intercept("localhost", 8080, bottle.default_app)
|
||||||
twill.add_wsgi_intercept("systemexit.de", 80, bottle.default_app)
|
twill.add_wsgi_intercept("systemexit.de", 80, bottle.default_app)
|
||||||
|
twill.add_wsgi_intercept("pypi.python.org", 80, lambda: fallback_app)
|
||||||
|
|
||||||
go("http://localhost:8080/")
|
go("http://localhost:8080/")
|
||||||
return tmpdir
|
return tmpdir
|
||||||
@ -57,3 +65,14 @@ def test_favicon(root):
|
|||||||
assert final_url == "http://localhost:8080/favicon.ico"
|
assert final_url == "http://localhost:8080/favicon.ico"
|
||||||
code(404)
|
code(404)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fallback(root):
|
||||||
|
assert core.config.redirect_to_fallback
|
||||||
|
final_url = go("/simple/pypiserver/")
|
||||||
|
assert final_url == "http://pypi.python.org/simple/pypiserver/"
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_fallback(root):
|
||||||
|
core.config.redirect_to_fallback = False
|
||||||
|
final_url = go("/simple/pypiserver/")
|
||||||
|
assert final_url == "http://localhost:8080/simple/pypiserver/"
|
||||||
|
Loading…
Reference in New Issue
Block a user