b6709997cc
The demo app is of somewhat niche interest and is disabled by default but arguable that makes it more important to document it fully since this app is harder to find the many others. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
import pytest
|
|
import wasp
|
|
import importlib
|
|
import os
|
|
|
|
EXCLUDE = ('Notifications', 'Template', 'Faces')
|
|
|
|
def test_README(constructor):
|
|
if constructor.NAME in EXCLUDE:
|
|
return
|
|
fname = f'res/{constructor.NAME}App.png'.replace(' ', '')
|
|
|
|
# A screenshot must exist for every application (press 's' in the
|
|
# simulator)
|
|
assert os.path.exists(fname)
|
|
|
|
# Every screenshot must be included in the README image gallery
|
|
with open('README.rst') as f:
|
|
readme = f.read()
|
|
assert fname in readme
|
|
|
|
def test_app_library(constructor):
|
|
if constructor.NAME in EXCLUDE:
|
|
return
|
|
|
|
with open('docs/apps.rst') as f:
|
|
appdoc = f.read()
|
|
with open('docs/wasp.rst') as f:
|
|
waspdoc = f.read()
|
|
|
|
# Every application must be listed in the Application Library
|
|
needle = f'.. automodule:: {constructor.__module__}'
|
|
assert needle in appdoc
|
|
|
|
def test_docstrings(constructor):
|
|
if constructor.NAME in EXCLUDE:
|
|
return
|
|
fname = f'res/{constructor.NAME}App.png'.replace(' ', '')
|
|
|
|
class_doc = constructor.__doc__
|
|
module_doc = importlib.import_module(constructor.__module__).__doc__
|
|
|
|
# Screenshots should *not* appear in the constructor.
|
|
if constructor.__doc__:
|
|
assert fname not in constructor.__doc__
|
|
|
|
# Screenshots should appear in the full module documentation
|
|
assert f'.. figure:: {fname }' in module_doc
|
|
|
|
# The second line of the module documentation should be an
|
|
# underline (e.g. the first line must be a section header)
|
|
assert(module_doc.split('\n')[1].startswith('~~~~'))
|