-
-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit test that checks that all plugin hooks have corresponding unit tests #771
Labels
Milestone
Comments
This seems to work: diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index 8b6a6b4..e9a40aa 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -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,21 @@ import pytest
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')" Based on how the documentation unit tests work. Currently fails with:
|
simonw
added a commit
that referenced
this issue
May 27, 2020
I'll do the work for this in the pull request #772. |
Actually I'll land this using |
|
simonw
added a commit
that referenced
this issue
May 27, 2020
Closed in da87e96 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns out some hooks are missing unit test coverage: #581 (comment)_
The text was updated successfully, but these errors were encountered: