Better tests for prepare_connection() plugin hook, refs #678

This commit is contained in:
Simon Willison 2020-02-21 18:27:07 -08:00
commit 7c6a9c3529
2 changed files with 16 additions and 2 deletions

View file

@ -10,13 +10,22 @@ import pytest
import urllib
def test_plugins_dir_plugin(app_client):
def test_plugins_dir_plugin_prepare_connection(app_client):
response = app_client.get(
"/fixtures.json?sql=select+convert_units(100%2C+'m'%2C+'ft')"
)
assert pytest.approx(328.0839) == response.json["rows"][0][0]
def test_plugin_prepare_connection_arguments(app_client):
response = app_client.get(
"/fixtures.json?sql=select+prepare_connection_args()&_shape=arrayfirst"
)
assert [
"database=fixtures, datasette.plugin_config(\"name-of-plugin\")={'depth': 'root'}"
] == response.json
@pytest.mark.parametrize(
"path,expected_decoded_object",
[