mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Documentation for filters, plus new documentation unit test
https://simonwillison.net/2018/Jul/28/documentation-unit-tests/
This commit is contained in:
parent
6da567dda9
commit
2c19a27d15
2 changed files with 79 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ Tests to ensure certain things are documented.
|
|||
from click.testing import CliRunner
|
||||
from datasette import app
|
||||
from datasette.cli import cli
|
||||
from datasette.filters import Filters
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
import re
|
||||
|
|
@ -71,3 +72,20 @@ def documented_views():
|
|||
@pytest.mark.parametrize("view_class", [v for v in dir(app) if v.endswith("View")])
|
||||
def test_view_classes_are_documented(documented_views, view_class):
|
||||
assert view_class in documented_views
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def documented_table_filters():
|
||||
json_api_rst = (docs_path / "json_api.rst").read_text()
|
||||
section = json_api_rst.split(".. _table_arguments:")[-1]
|
||||
# Lines starting with ``?column__exact= are docs for filters
|
||||
return set(
|
||||
line.split("__")[1].split("=")[0]
|
||||
for line in section.split("\n")
|
||||
if line.startswith("``?column__")
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("filter", [f.key for f in Filters._filters])
|
||||
def test_table_filters_are_documented(documented_table_filters, filter):
|
||||
assert filter in documented_table_filters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue