mirror of
https://github.com/simonw/datasette.git
synced 2026-07-08 16:44:34 +02:00
Use UNSTABLE_API_MESSAGE constant in tests
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GrHZSypDfMnym1tM5XJAFZ
This commit is contained in:
parent
57ce1a059f
commit
4a853cb10c
4 changed files with 11 additions and 22 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from datasette.app import Datasette
|
||||
from datasette.plugins import DEFAULT_PLUGINS
|
||||
from datasette.utils import UNSTABLE_API_MESSAGE
|
||||
from datasette.utils.sqlite import sqlite_version
|
||||
from datasette.version import __version__
|
||||
from .fixtures import make_app_client, EXPECTED_PLUGINS
|
||||
|
|
@ -251,10 +252,7 @@ def test_no_files_uses_memory_database(app_client_no_files):
|
|||
assert response.status == 200
|
||||
assert {
|
||||
"ok": True,
|
||||
"unstable": (
|
||||
"This API is not part of Datasette's stable interface"
|
||||
" and may change at any time"
|
||||
),
|
||||
"unstable": UNSTABLE_API_MESSAGE,
|
||||
"databases": [
|
||||
{
|
||||
"name": "_memory",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from asgiref.sync import async_to_sync
|
|||
from datasette.app import Datasette
|
||||
from datasette.cli import cli
|
||||
from datasette.default_permissions import restrictions_allow_action
|
||||
from datasette.utils import UNSTABLE_API_MESSAGE
|
||||
from .fixtures import assert_permissions_checked, make_app_client
|
||||
from click.testing import CliRunner
|
||||
from bs4 import BeautifulSoup as Soup
|
||||
|
|
@ -740,10 +741,7 @@ async def test_actor_restricted_permissions(
|
|||
}
|
||||
expected = {
|
||||
"ok": True,
|
||||
"unstable": (
|
||||
"This API is not part of Datasette's stable interface"
|
||||
" and may change at any time"
|
||||
),
|
||||
"unstable": UNSTABLE_API_MESSAGE,
|
||||
"action": permission,
|
||||
"allowed": expected_result,
|
||||
"resource": expected_resource,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from bs4 import BeautifulSoup as Soup
|
|||
from datasette.app import Datasette
|
||||
from datasette.resources import DatabaseResource, QueryResource
|
||||
from datasette.stored_queries import StoredQuery, StoredQueryPage
|
||||
from datasette.utils import UNSTABLE_API_MESSAGE
|
||||
from datasette.utils.asgi import Forbidden
|
||||
from datasette.utils.sqlite import sqlite3, supports_returning
|
||||
|
||||
|
|
@ -2183,10 +2184,7 @@ async def test_query_parameters_endpoint_uses_get_sql_only():
|
|||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"ok": True,
|
||||
"unstable": "{}".format(
|
||||
"This API is not part of Datasette's stable interface"
|
||||
" and may change at any time"
|
||||
),
|
||||
"unstable": UNSTABLE_API_MESSAGE,
|
||||
"parameters": ["name", "id"],
|
||||
}
|
||||
assert permission_denied_response.status_code == 403
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ objects separately - see /-/plugins, /-/databases, /-/actions.)
|
|||
|
||||
import pytest
|
||||
from datasette.app import Datasette
|
||||
from datasette.utils import sqlite3
|
||||
from datasette.utils import sqlite3, UNSTABLE_API_MESSAGE
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
@ -114,11 +114,6 @@ async def test_actions_json_is_object(ds_envelope):
|
|||
assert "view-instance" in {action["name"] for action in data["actions"]}
|
||||
|
||||
|
||||
UNSTABLE_MESSAGE = (
|
||||
"This API is not part of Datasette's stable interface and may change at any time"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"path",
|
||||
|
|
@ -137,7 +132,7 @@ async def test_undocumented_endpoints_report_unstable(ds_client, path):
|
|||
finally:
|
||||
ds_client.ds.root_enabled = False
|
||||
assert response.status_code == 200
|
||||
assert response.json()["unstable"] == UNSTABLE_MESSAGE
|
||||
assert response.json()["unstable"] == UNSTABLE_API_MESSAGE
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -148,12 +143,12 @@ async def test_query_store_and_definition_report_unstable(ds_envelope):
|
|||
actor={"id": "root"},
|
||||
)
|
||||
assert store.status_code == 201
|
||||
assert store.json()["unstable"] == UNSTABLE_MESSAGE
|
||||
assert store.json()["unstable"] == UNSTABLE_API_MESSAGE
|
||||
definition = await ds_envelope.client.get(
|
||||
"/data/unstable_check/-/definition", actor={"id": "root"}
|
||||
)
|
||||
assert definition.status_code == 200
|
||||
assert definition.json()["unstable"] == UNSTABLE_MESSAGE
|
||||
assert definition.json()["unstable"] == UNSTABLE_API_MESSAGE
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -164,7 +159,7 @@ async def test_permissions_post_reports_unstable(ds_envelope):
|
|||
actor={"id": "root"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["unstable"] == UNSTABLE_MESSAGE
|
||||
assert response.json()["unstable"] == UNSTABLE_API_MESSAGE
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue