mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New "startup" plugin hook, closes #834
This commit is contained in:
parent
b906030235
commit
09a3479a54
8 changed files with 61 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ EXPECTED_PLUGINS = [
|
|||
"register_facet_classes",
|
||||
"register_routes",
|
||||
"render_cell",
|
||||
"startup",
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -167,3 +167,8 @@ def register_routes():
|
|||
(r"/two/(?P<name>.*)$", two),
|
||||
(r"/three/$", three),
|
||||
]
|
||||
|
||||
|
||||
@hookimpl
|
||||
def startup(datasette):
|
||||
datasette._startup_hook_fired = True
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from click.testing import CliRunner
|
|||
import io
|
||||
import json
|
||||
import pathlib
|
||||
import pytest
|
||||
import textwrap
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -572,3 +572,9 @@ def test_register_routes_asgi(app_client):
|
|||
response = app_client.get("/three/")
|
||||
assert {"hello": "world"} == response.json
|
||||
assert "1" == response.headers["x-three"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_startup(app_client):
|
||||
await app_client.ds.invoke_startup()
|
||||
assert app_client.ds._startup_hook_fired
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue