kopia lustrzana https://github.com/simonw/datasette
Unit test confirming all plugin hooks are documented
rodzic
ba64cfb4bc
commit
3ac21c7498
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue