kopia lustrzana https://github.com/simonw/datasette
A bunch of remaining ds_client conversions, refs #1959
rodzic
be95359a80
commit
42a66c2f04
|
@ -1010,6 +1010,7 @@ async def test_http_options_request(ds_client):
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_db_path(app_client):
|
||||
# Needs app_client because needs file based database
|
||||
db = app_client.ds.get_database()
|
||||
path = pathlib.Path(db.path)
|
||||
|
||||
|
|
|
@ -485,6 +485,7 @@ def test_database_download_for_immutable():
|
|||
|
||||
|
||||
def test_database_download_disallowed_for_mutable(app_client):
|
||||
# Use app_client because we need a file database, not in-memory
|
||||
response = app_client.get("/fixtures")
|
||||
soup = Soup(response.content, "html.parser")
|
||||
assert len(soup.findAll("a", {"href": re.compile(r"\.db$")})) == 0
|
||||
|
|
|
@ -4,13 +4,12 @@ Tests for the datasette.app.Datasette class
|
|||
from datasette import Forbidden
|
||||
from datasette.app import Datasette, Database
|
||||
from itsdangerous import BadSignature
|
||||
from .fixtures import app_client
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def datasette(app_client):
|
||||
return app_client.ds
|
||||
def datasette(ds_client):
|
||||
return ds_client.ds
|
||||
|
||||
|
||||
def test_get_database(datasette):
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
from .fixtures import app_client
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def datasette(app_client):
|
||||
await app_client.ds.invoke_startup()
|
||||
return app_client.ds
|
||||
async def datasette(ds_client):
|
||||
await ds_client.ds.invoke_startup()
|
||||
return ds_client.ds
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from .fixtures import app_client
|
||||
from .utils import cookie_was_deleted
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.ds_client
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"qs,expected",
|
||||
[
|
||||
|
@ -11,18 +12,20 @@ import pytest
|
|||
("add_msg=added-error&type=ERROR", [["added-error", 3]]),
|
||||
],
|
||||
)
|
||||
def test_add_message_sets_cookie(app_client, qs, expected):
|
||||
response = app_client.get(f"/fixtures.message?{qs}")
|
||||
async def test_add_message_sets_cookie(ds_client, qs, expected):
|
||||
response = await ds_client.get(f"/fixtures.message?{qs}")
|
||||
signed = response.cookies["ds_messages"]
|
||||
decoded = app_client.ds.unsign(signed, "messages")
|
||||
decoded = ds_client.ds.unsign(signed, "messages")
|
||||
assert expected == decoded
|
||||
|
||||
|
||||
def test_messages_are_displayed_and_cleared(app_client):
|
||||
@pytest.mark.ds_client
|
||||
@pytest.mark.asyncio
|
||||
async def test_messages_are_displayed_and_cleared(ds_client):
|
||||
# First set the message cookie
|
||||
set_msg_response = app_client.get("/fixtures.message?add_msg=xmessagex")
|
||||
set_msg_response = await ds_client.get("/fixtures.message?add_msg=xmessagex")
|
||||
# Now access a page that displays messages
|
||||
response = app_client.get("/", cookies=set_msg_response.cookies)
|
||||
response = await ds_client.get("/", cookies=set_msg_response.cookies)
|
||||
# Messages should be in that HTML
|
||||
assert "xmessagex" in response.text
|
||||
# Cookie should have been set that clears messages
|
||||
|
|
Ładowanie…
Reference in New Issue