Skip to content

Commit

Permalink
Test that plugin hooks are tested, refs #771
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed May 27, 2020
1 parent 41a0cd7 commit df66552
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 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,21 @@
import urllib


def test_plugin_hooks_have_tests():
"Every plugin hook should be referenced in this test module"
hooks = [name for name in dir(pm.hook) if not name.startswith("_")]
tests_in_this_module = [t for t in globals().keys() if t.startswith("test_")]
untested = []
for hook in hooks:
ok = False
for test in tests_in_this_module:
if hook in test:
ok = True
if not ok:
untested.append(hook)
assert not untested, "These plugin hooks are missing tests: {}".format(untested)


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 df66552

Please sign in to comment.