mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
More documentation unit tests. These ones check that every single **View class
imported into the datasette/app.py module are covered by our documentation.
Just one problem: they aren't documented yet. So I'm using the xfail pytest
decorator to mark these tests as allowed-to-fail. When you run the test suite
you now get a report of how many views still need to be documented, but it
doesn't fail the tests.
The output looks something like this:
$ pytest tests/test_docs.py
collected 31 items
tests/test_docs.py ..........................XXXxx. [100%]
============ 26 passed, 2 xfailed, 3 xpassed in 1.06 seconds ============
Once I have documented all the views I will remove the xfail so any future
views that are added without documentation will cause a test failure.
We can detect that a view is documented by looking for ReST label in the docs,
for example:
.. _IndexView:
Some view classes can be used to power multiple URLs - the JsonDataView class
for example is used to power /-/metadata and /-/config and /-/plugins
In this case, the second part of the label can indicate the variety of page, e.g:
.. _JsonDataView_metadata:
The test will pass as long as there is at least one label that starts with
_JsonDataView.
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| fixtures.py | ||
| test_api.py | ||
| test_csv.py | ||
| test_docs.py | ||
| test_html.py | ||
| test_inspect.py | ||
| test_plugins.py | ||
| test_publish_heroku.py | ||
| test_publish_now.py | ||
| test_utils.py | ||