T
traeai
Sign in
返回首页
Simon Willison's Weblog

Release: datasette-fixtures 0.1a0

7.2Score

TL;DR · AI Summary

datasette-fixtures 0.1a0 provides a way to populate test databases, streamlining plugin development workflows.

Key Takeaways

  • Built on top of Datasette 1.0a30’s new API for creating fixture database tables.
  • Can be run directly via uvx command without installing Datasette.
  • Returns structured JSON output including ok, rows, and truncated fields for easy

Outline

Jump quickly between sections.

  1. datasette-fixtures is a plugin that creates test databases using Datasette's new APIs.

  2. It leverages the newly added populate_fixture_database API from Datasette 1.0a30.

  3. Users can execute the plugin directly through uvx without installing Datasette.

  4. Calling /fixtures/roadside_attractions.json returns predefined attraction data in JSON format.

Mindmap

See how the topics connect at a glance.

查看大纲文本(无障碍 / 无 JS 友好)
  • datasette-fixtures 0.1a0
    • Core Features
      • populate_fixture_database API
    • Usage
      • Run with uvx
      • JSON Output Format

Highlights

Key sentences worth saving and sharing.

  • New documented datasette.fixtures.populate_fixture_database(conn) helper for creating the fixture database tables used by Datasette's own tests.

    Paragraph 1

    ⬇︎ 下载 PNG𝕏 分享到 X
  • You can try it out using `uvx` without even installing Datasette like this:

    Paragraph 2

    ⬇︎ 下载 PNG𝕏 分享到 X
  • Which outputs: {"ok": true, "next": null, "rows": [...], "truncated": false}

    Paragraph 3

    ⬇︎ 下载 PNG𝕏 分享到 X
#Datasette#Python#Testing#Plugin Development
Open original article

One of the smaller features in Datasette 1.0a30 is this:

New documented datasette.fixtures.populate_fixture_database(conn) helper for creating the fixture database tables used by Datasette's own tests, intended for plugin test suites.

This new plugin takes advantage of that API. You can try it out using uvx without even installing Datasette like this:

uvx --prerelease=allow \ --with datasette-fixtures datasette \ --get /fixtures/roadside_attractions.json Which outputs:

{ "ok": true, "next": null, "rows": [ {"pk": 1, "name": "The Mystery Spot", "address": "465 Mystery Spot Road, Santa Cruz, CA 95065", "url": "https://www.mysteryspot.com/", "latitude": 37.0167, "longitude": -122.0024}, {"pk": 2, "name": "Winchester Mystery House", "address": "525 South Winchester Boulevard, San Jose, CA 95128", "url": "https://winchestermysteryhouse.com/", "latitude": 37.3184, "longitude": -121.9511}, {"pk": 3, "name": "Burlingame Museum of PEZ Memorabilia", "address": "214 California Drive, Burlingame, CA 94010", "url": null, "latitude": 37.5793, "longitude": -122.3442}, {"pk": 4, "name": "Bigfoot Discovery Museum", "address": "5497 Highway 9, Felton, CA 95018", "url": "https://www.bigfootdiscoveryproject.com/", "latitude": 37.0414, "longitude": -122.0725} ], "truncated": false }

AI may generate inaccurate information. Please verify important content.