From 4a853cb10ca6fd0c1aaecf0af7dd26665424c540 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 7 Jul 2026 05:18:54 +0000 Subject: [PATCH] Use UNSTABLE_API_MESSAGE constant in tests Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GrHZSypDfMnym1tM5XJAFZ --- tests/test_api.py | 6 ++---- tests/test_permissions.py | 6 ++---- tests/test_queries.py | 6 ++---- tests/test_success_envelope.py | 15 +++++---------- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index a15a507c..235d394b 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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", diff --git a/tests/test_permissions.py b/tests/test_permissions.py index f8d2c808..88fe577f 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -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, diff --git a/tests/test_queries.py b/tests/test_queries.py index 1cda740e..a7e492eb 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -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 diff --git a/tests/test_success_envelope.py b/tests/test_success_envelope.py index 68b042e5..3c413d73 100644 --- a/tests/test_success_envelope.py +++ b/tests/test_success_envelope.py @@ -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