sections_fts: 16
This data as json
| rowid | title | content |
|---|---|---|
| 16 | Using Datasette's fixtures database | Datasette's own test suite uses a SQLite database with tables that exercise features such as compound primary keys, foreign keys, sortable columns, facets, full-text search and binary data. You can use those same tables in your plugin tests using the populate_fixture_database(conn) helper in datasette.fixtures : Be aware that future Datasette releases may change details of these tables, so try not to rely on their exact structure in your own tests. populate_fixture_database(conn) Populates an existing SQLite connection with the fixture tables. For an in-memory test database: from datasette.app import Datasette from datasette.fixtures import populate_fixture_database import pytest import pytest_asyncio @pytest_asyncio.fixture async def datasette(): datasette = Datasette() db = datasette.add_memory_database("fixtures") await db.execute_write_fn(populate_fixture_database) await datasette.invoke_startup() return datasette @pytest.mark.asyncio async def test_facetable(datasette): response = await datasette.client.get( "/fixtures/facetable.json?_shape=array" ) assert response.status_code == 200 |