2021-01-12 23:02:31 +01:00
|
|
|
import pytest
|
|
|
|
import wasp
|
2021-01-13 22:51:17 +01:00
|
|
|
import importlib
|
2021-01-12 23:02:31 +01:00
|
|
|
import os
|
|
|
|
|
2021-06-20 11:43:25 +02:00
|
|
|
EXCLUDE = ('Notifications', 'Template', 'Faces')
|
2021-01-12 23:02:31 +01:00
|
|
|
|
2021-01-13 23:14:33 +01:00
|
|
|
def test_README(constructor):
|
2021-01-12 23:02:31 +01:00
|
|
|
if constructor.NAME in EXCLUDE:
|
|
|
|
return
|
|
|
|
fname = f'res/{constructor.NAME}App.png'.replace(' ', '')
|
2021-01-13 22:51:17 +01:00
|
|
|
|
|
|
|
# A screenshot must exist for every application (press 's' in the
|
|
|
|
# simulator)
|
2021-01-12 23:02:31 +01:00
|
|
|
assert os.path.exists(fname)
|
|
|
|
|
2021-01-13 22:51:17 +01:00
|
|
|
# Every screenshot must be included in the README image gallery
|
2021-01-12 23:02:31 +01:00
|
|
|
with open('README.rst') as f:
|
|
|
|
readme = f.read()
|
|
|
|
assert fname in readme
|
2021-01-12 23:33:25 +01:00
|
|
|
|
2021-01-13 22:51:17 +01:00
|
|
|
def test_app_library(constructor):
|
2021-01-12 23:33:25 +01:00
|
|
|
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()
|
|
|
|
|
2021-01-13 23:14:33 +01:00
|
|
|
# Every application must be listed in the Application Library
|
2021-01-12 23:33:25 +01:00
|
|
|
needle = f'.. automodule:: {constructor.__module__}'
|
2021-01-13 23:14:33 +01:00
|
|
|
assert needle in appdoc
|
2021-01-13 22:51:17 +01:00
|
|
|
|
|
|
|
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('~~~~'))
|