kopia lustrzana https://github.com/simonw/datasette
New app_client_base_url_prefix fixture
rodzic
d3e9b0aecb
commit
29a977a74e
|
@ -159,6 +159,12 @@ def app_client_no_files():
|
|||
yield TestClient(ds)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app_client_base_url_prefix():
|
||||
with make_app_client(config={"base_url": "/prefix/"}) as client:
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app_client_two_attached_databases():
|
||||
with make_app_client(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from bs4 import BeautifulSoup as Soup
|
||||
from .fixtures import ( # noqa
|
||||
app_client,
|
||||
app_client_base_url_prefix,
|
||||
app_client_shorter_time_limit,
|
||||
app_client_two_attached_databases,
|
||||
app_client_with_hash,
|
||||
|
@ -1371,10 +1372,9 @@ def test_metadata_sort_desc(app_client):
|
|||
"/fixtures/facetable",
|
||||
],
|
||||
)
|
||||
def test_base_url_config(path):
|
||||
base_url = "/prefix/"
|
||||
with make_app_client(config={"base_url": base_url}) as client:
|
||||
response = client.get(base_url + path.lstrip("/"))
|
||||
def test_base_url_config(app_client_base_url_prefix, path):
|
||||
client = app_client_base_url_prefix
|
||||
response = client.get("/prefix/" + path.lstrip("/"))
|
||||
soup = Soup(response.body, "html.parser")
|
||||
for el in soup.findAll(["a", "link", "script"]):
|
||||
if "href" in el.attrs:
|
||||
|
@ -1396,8 +1396,7 @@ def test_base_url_config(path):
|
|||
# If this has been made absolute it may start http://localhost/
|
||||
if href.startswith("http://localhost/"):
|
||||
href = href[len("http://localost/") :]
|
||||
assert href.startswith(base_url), {
|
||||
"base_url": base_url,
|
||||
assert href.startswith("/prefix/"), {
|
||||
"path": path,
|
||||
"href_or_src": href,
|
||||
"element_parent": str(el.parent),
|
||||
|
|
Ładowanie…
Reference in New Issue