mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Remove hashed URL mode
Also simplified how view class routing works. Refs #1661
This commit is contained in:
parent
30e5f0e67c
commit
d4f60c2388
12 changed files with 79 additions and 266 deletions
|
|
@ -21,61 +21,61 @@ def custom_pages_client_with_base_url():
|
|||
|
||||
def test_custom_pages_view_name(custom_pages_client):
|
||||
response = custom_pages_client.get("/about")
|
||||
assert 200 == response.status
|
||||
assert "ABOUT! view_name:page" == response.text
|
||||
assert response.status == 200
|
||||
assert response.text == "ABOUT! view_name:page"
|
||||
|
||||
|
||||
def test_request_is_available(custom_pages_client):
|
||||
response = custom_pages_client.get("/request")
|
||||
assert 200 == response.status
|
||||
assert "path:/request" == response.text
|
||||
assert response.status == 200
|
||||
assert response.text == "path:/request"
|
||||
|
||||
|
||||
def test_custom_pages_with_base_url(custom_pages_client_with_base_url):
|
||||
response = custom_pages_client_with_base_url.get("/prefix/request")
|
||||
assert 200 == response.status
|
||||
assert "path:/prefix/request" == response.text
|
||||
assert response.status == 200
|
||||
assert response.text == "path:/prefix/request"
|
||||
|
||||
|
||||
def test_custom_pages_nested(custom_pages_client):
|
||||
response = custom_pages_client.get("/nested/nest")
|
||||
assert 200 == response.status
|
||||
assert "Nest!" == response.text
|
||||
assert response.status == 200
|
||||
assert response.text == "Nest!"
|
||||
response = custom_pages_client.get("/nested/nest2")
|
||||
assert 404 == response.status
|
||||
assert response.status == 404
|
||||
|
||||
|
||||
def test_custom_status(custom_pages_client):
|
||||
response = custom_pages_client.get("/202")
|
||||
assert 202 == response.status
|
||||
assert "202!" == response.text
|
||||
assert response.status == 202
|
||||
assert response.text == "202!"
|
||||
|
||||
|
||||
def test_custom_headers(custom_pages_client):
|
||||
response = custom_pages_client.get("/headers")
|
||||
assert 200 == response.status
|
||||
assert "foo" == response.headers["x-this-is-foo"]
|
||||
assert "bar" == response.headers["x-this-is-bar"]
|
||||
assert "FOOBAR" == response.text
|
||||
assert response.status == 200
|
||||
assert response.headers["x-this-is-foo"] == "foo"
|
||||
assert response.headers["x-this-is-bar"] == "bar"
|
||||
assert response.text == "FOOBAR"
|
||||
|
||||
|
||||
def test_custom_content_type(custom_pages_client):
|
||||
response = custom_pages_client.get("/atom")
|
||||
assert 200 == response.status
|
||||
assert response.status == 200
|
||||
assert response.headers["content-type"] == "application/xml"
|
||||
assert "<?xml ...>" == response.text
|
||||
assert response.text == "<?xml ...>"
|
||||
|
||||
|
||||
def test_redirect(custom_pages_client):
|
||||
response = custom_pages_client.get("/redirect")
|
||||
assert 302 == response.status
|
||||
assert "/example" == response.headers["Location"]
|
||||
assert response.status == 302
|
||||
assert response.headers["Location"] == "/example"
|
||||
|
||||
|
||||
def test_redirect2(custom_pages_client):
|
||||
response = custom_pages_client.get("/redirect2")
|
||||
assert 301 == response.status
|
||||
assert "/example" == response.headers["Location"]
|
||||
assert response.status == 301
|
||||
assert response.headers["Location"] == "/example"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue