This commit is contained in:
agustin18 2026-10-15 16:44:26 +00:00 • committed by GitHub
commit cfb359cee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View file

@ -1497,7 +1497,7 @@ class Datasette:
# fallback to top-level if needed
if db_plugin_config is None and fallback:
self._plugin_config_top(plugin_name)
return self._plugin_config_top(plugin_name)
return db_plugin_config

View file

@ -301,6 +301,34 @@ async def test_plugin_config(ds_client):
assert None is ds_client.ds.plugin_config("unknown-plugin")
@pytest.mark.parametrize(
"database,table,fallback,expected",
[
("configured_db", None, True, {"setting": "top"}),
("configured_db", None, False, None),
("configured_db", "some_table", True, {"setting": "top"}),
("configured_db", "some_table", False, None),
],
)
def test_plugin_config_top_fallback_when_table_none(
database, table, fallback, expected
):
datasette = Datasette(
config={
"plugins": {"test-plugin": {"setting": "top"}},
"databases": {
"configured_db": {"description": "A database without plugin config"}
},
}
)
assert (
datasette.plugin_config(
"test-plugin", database=database, table=table, fallback=fallback
)
== expected
)
@pytest.mark.asyncio
async def test_plugin_config_env(ds_client, monkeypatch):
monkeypatch.setenv("FOO_ENV", "FROM_ENVIRONMENT")