Unit test confirming all plugin hooks are documented

pull/349/head
Simon Willison 2018-07-25 21:09:33 -07:00
rodzic ba64cfb4bc
commit 3ac21c7498
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 17E2DEA2588B7F52
1 zmienionych plików z 17 dodań i 4 usunięć

Wyświetl plik

@ -9,14 +9,17 @@ import pytest
import re
docs_path = Path(__file__).parent.parent / 'docs'
markdown = (docs_path / 'config.rst').open().read()
setting_heading_re = re.compile(r'(\w+)\n\-+\n')
setting_headings = set(setting_heading_re.findall(markdown))
def get_headings(filename, underline="-"):
markdown = (docs_path / filename).open().read()
heading_re = re.compile(r'(\S+)\n\{}+\n'.format(underline))
return set(heading_re.findall(markdown))
@pytest.mark.parametrize('config', app.CONFIG_OPTIONS)
def test_config_options_are_documented(config):
assert config.name in setting_headings
assert config.name in get_headings("config.rst")
@pytest.mark.parametrize('name,filename', (
@ -35,3 +38,13 @@ def test_help_includes(name, filename):
# because it doesn't know that cli will be aliased to datasette
expected = expected.replace('Usage: datasette', 'Usage: cli')
assert expected == actual
@pytest.mark.parametrize('plugin', [
name for name in dir(app.pm.hook) if not name.startswith('_')
])
def test_plugin_hooks_are_documented(plugin):
headings = [
s.split("(")[0] for s in get_headings("plugins.rst", "~")
]
assert plugin in headings