mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Unit test confirming all plugin hooks are documented
This commit is contained in:
parent
ba64cfb4bc
commit
3ac21c7498
1 changed files with 17 additions and 4 deletions
|
|
@ -9,14 +9,17 @@ import pytest
|
||||||
import re
|
import re
|
||||||
|
|
||||||
docs_path = Path(__file__).parent.parent / 'docs'
|
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)
|
@pytest.mark.parametrize('config', app.CONFIG_OPTIONS)
|
||||||
def test_config_options_are_documented(config):
|
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', (
|
@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
|
# because it doesn't know that cli will be aliased to datasette
|
||||||
expected = expected.replace('Usage: datasette', 'Usage: cli')
|
expected = expected.replace('Usage: datasette', 'Usage: cli')
|
||||||
assert expected == actual
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue