Test that plugin hooks are unit tested (xfail)

This currently fails using xfail. Closes 771.
This commit is contained in:
Simon Willison 2020-05-27 13:16:02 -07:00 committed by GitHub
commit da87e963bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,7 @@ from .fixtures import (
TestClient as _TestClient,
) # noqa
from datasette.app import Datasette
from datasette.plugins import get_plugins, DEFAULT_PLUGINS
from datasette.plugins import get_plugins, DEFAULT_PLUGINS, pm
from datasette.utils import sqlite3
import base64
import json
@ -20,6 +20,20 @@ import pytest
import urllib
@pytest.mark.xfail
@pytest.mark.parametrize(
"plugin_hook", [name for name in dir(pm.hook) if not name.startswith("_")]
)
def test_plugin_hooks_have_tests(plugin_hook):
"Every plugin hook should be referenced in this test module"
tests_in_this_module = [t for t in globals().keys() if t.startswith("test_")]
ok = False
for test in tests_in_this_module:
if plugin_hook in test:
ok = True
assert ok, "Plugin hook is missing tests: {}".format(plugin_hook)
def test_plugins_dir_plugin_prepare_connection(app_client):
response = app_client.get(
"/fixtures.json?sql=select+convert_units(100%2C+'m'%2C+'ft')"