Skip to content

Commit

Permalink
Test that plugin hooks are unit tested (xfail)
Browse files Browse the repository at this point in the history
This currently fails using xfail. Closes 771.
  • Loading branch information
simonw authored May 27, 2020
1 parent 41a0cd7 commit da87e96
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand All @@ -20,6 +20,20 @@
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')"
Expand Down

0 comments on commit da87e96

Please sign in to comment.