diff --git a/setup.py b/setup.py index 79c2226..b1c1aee 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,15 @@ setup( "console_scripts": ["dclient = dclient.cli:cli"], }, install_requires=["click", "httpx", "appdirs"], - extras_require={"test": ["pytest", "pytest-httpx", "cogapp", "pytest-mock"]}, + extras_require={ + "test": [ + "pytest", + "pytest-asyncio", + "pytest-httpx", + "cogapp", + "pytest-mock", + "datasette", + ] + }, python_requires=">=3.7", ) diff --git a/tests/test_datasette_plugin.py b/tests/test_datasette_plugin.py new file mode 100644 index 0000000..05d3c80 --- /dev/null +++ b/tests/test_datasette_plugin.py @@ -0,0 +1,23 @@ +from click.testing import CliRunner +from datasette.app import Datasette +from datasette.cli import cli +import pytest + + +def test_plugin_help(): + runner = CliRunner() + result = runner.invoke(cli, ["client", "--help"]) + assert result.exit_code == 0 + assert "Usage: cli client" in result.output + bits = result.output.split("Commands:") + assert "alias" in bits[1] + assert "query" in bits[1] + + +@pytest.mark.asyncio +async def test_plugin_installed(): + ds = Datasette(memory=True) + await ds.invoke_startup() + response = await ds.client.get("/-/plugins.json") + assert response.status_code == 200 + assert any(p["name"] == "dclient" for p in response.json())