kopia lustrzana https://github.com/simonw/datasette
Documentation for Datasette() constructor, closes #1563
rodzic
3a0cae4d7f
commit
7c8f8aa209
|
@ -196,6 +196,27 @@ Datasette class
|
|||
|
||||
This object is an instance of the ``Datasette`` class, passed to many plugin hooks as an argument called ``datasette``.
|
||||
|
||||
You can create your own instance of this - for example to help write tests for a plugin - like so:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from datasette.app import Datasette
|
||||
|
||||
# With no arguments a single in-memory database will be attached
|
||||
datasette = Datasette()
|
||||
|
||||
# The files= argument can load files from disk
|
||||
datasette = Datasette(files="/path/to/my-database.db")
|
||||
|
||||
# Pass metadata as a JSON dictionary like this
|
||||
datasette = Datasette(files="/path/to/my-database.db", metadata={
|
||||
"databases": {
|
||||
"my-database": {
|
||||
"description": "This is my database"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.. _datasette_databases:
|
||||
|
||||
.databases
|
||||
|
|
|
@ -50,7 +50,7 @@ def test_datasette_setting(datasette, setting, expected):
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_datasette_constructor():
|
||||
ds = Datasette(memory=True)
|
||||
ds = Datasette()
|
||||
databases = (await ds.client.get("/-/databases.json")).json()
|
||||
assert databases == [
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue