Skip to main content

Utilities to help write tests for Datasette plugins and applications

Project description

datasette-test

PyPI Tests Changelog License

Utilities to help write tests for Datasette plugins and applications

Installation

Install this library using pip:

pip install datasette-test

Tests that use plugin configuration

Datasette 1.0a8 enforced a configuration change where plugins are no longer configured in metadata, but instead use a configuration file.

This can result in test failures in projects that use the Datasette(metadata={"plugins": {"...": "..."}}) pattern to test out plugin configuration.

You can solve this using datasette_test.Datasette, a subclass that works with Datasette versions both before and after this breaking change:

from datasette_test import Datasette
import pytest

@pytest.mark.asyncio
async def test_datasette():
    ds = Datasette(plugin_config={"my-plugin": {"config": "goes here"})

This subclass detects if the underlying plugin needs configuration in metadata or config and instantiates the class correctly either way.

You can also use this class while continuing to pass metadata={"plugins": ...} - the class will move that configuration to config when necessary.

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd datasette-test
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette-test-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasette_test-0.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file datasette-test-0.1.1.tar.gz.

File metadata

  • Download URL: datasette-test-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for datasette-test-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ccdd1f824ccd8662ecf764694f4b09b2cf7482c23f6efadc4a0c5dbe728bb3f
MD5 42f43ed95c257ef5e81676487ce78324
BLAKE2b-256 5a308e97b096e3f849a8870c223bf8af3c1e16cfa4defd7d8e785954c1acfb46

See more details on using hashes here.

File details

Details for the file datasette_test-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: datasette_test-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for datasette_test-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e18a7fb5b61bfb7bdb49f02db2186b1b3a07c0113a5f8b23b6c373f220aac458
MD5 0ce253e22ce16da9162d920c2182e34d
BLAKE2b-256 48eb042f5eb868ffc638a38f7d6aaab3d61af82b39b13edfe842edde12053a6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page