mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Reset _metadata_local in a couple of tests
Refs https://github.com/simonw/datasette/pull/1960#issuecomment-1356476886
This commit is contained in:
parent
9c43b4164d
commit
89cffcf14c
2 changed files with 44 additions and 34 deletions
|
|
@ -582,12 +582,16 @@ async def test_facet_size():
|
|||
data5 = response5.json()
|
||||
assert len(data5["facet_results"]["city"]["results"]) == 20
|
||||
# Now try messing with facet_size in the table metadata
|
||||
orig_metadata = ds._metadata_local
|
||||
try:
|
||||
ds._metadata_local = {
|
||||
"databases": {
|
||||
"test_facet_size": {"tables": {"neighbourhoods": {"facet_size": 6}}}
|
||||
}
|
||||
}
|
||||
response6 = await ds.client.get("/test_facet_size/neighbourhoods.json?_facet=city")
|
||||
response6 = await ds.client.get(
|
||||
"/test_facet_size/neighbourhoods.json?_facet=city"
|
||||
)
|
||||
data6 = response6.json()
|
||||
assert len(data6["facet_results"]["city"]["results"]) == 6
|
||||
# Setting it to max bumps it up to 50 again
|
||||
|
|
@ -598,6 +602,8 @@ async def test_facet_size():
|
|||
await ds.client.get("/test_facet_size/neighbourhoods.json?_facet=city")
|
||||
).json()
|
||||
assert len(data7["facet_results"]["city"]["results"]) == 20
|
||||
finally:
|
||||
ds._metadata_local = orig_metadata
|
||||
|
||||
|
||||
def test_other_types_of_facet_in_metadata():
|
||||
|
|
|
|||
|
|
@ -990,6 +990,8 @@ def test_hook_skip_csrf(app_client):
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hook_get_metadata(ds_client):
|
||||
try:
|
||||
orig_metadata = ds_client.ds._metadata_local
|
||||
ds_client.ds._metadata_local = {
|
||||
"title": "Testing get_metadata hook!",
|
||||
"databases": {"from-local": {"title": "Hello from local metadata"}},
|
||||
|
|
@ -1012,6 +1014,8 @@ async def test_hook_get_metadata(ds_client):
|
|||
assert "Hello from local metadata" == meta["databases"]["from-local"]["title"]
|
||||
assert "Hello from the plugin hook" == meta["databases"]["from-hook"]["title"]
|
||||
pm.hook.get_metadata = og_pm_hook_get_metadata
|
||||
finally:
|
||||
ds_client.ds._metadata_local = orig_metadata
|
||||
|
||||
|
||||
def _extract_commands(output):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue