mirror of
https://github.com/simonw/datasette.git
synced 2026-10-18 15:26:57 +02:00
Merge 49a3d3dfc0 into c435a80030
This commit is contained in:
commit
cfb359cee6
2 changed files with 29 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue