This commit is contained in:
Correl Roush 2021-04-16 01:10:54 -04:00 committed by Correl Roush
parent 7ad0971612
commit 484d30e2de
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,45 @@
#+title: OpenAPI Test Coverage
Reporting coverage of OpenAPI request and response specifications using [[file:20210415110902-tornado_openapi_3.org][Tornado
OpenAPI 3]].
* Things that can be covered
- Requests by path and operation
- Responses by code
- Schemas?
* Writing a Python coverage plugin
- [[https://coverage.readthedocs.io/en/coverage-5.5/api_plugin.html#api-plugin][Plug-in classes]]
Traced files can be determined dynamically based on execution frames ([[https://docs.python.org/3/library/inspect.html][frame
objects]] are passed to plugin functions). This means I'll be able to create
simplified file-like representations of OpenAPI specifications, marking lines of
them as executable, and reporting on which ones should be marked as executed
based on the how the validator was run.
#+CAPTION: Plugin WIP
#+begin_src python
import coverage.plugin
class OpenAPITemplatePlugin(coverage.plugin.CoveragePlugin, coverage.plugin.FileTracer):
def __init__(self):
self.specs = {}
def sys_info(self):
return [("hi", "mom")]
def file_tracer(self, filename):
return None
def has_dynamic_source_filename():
return True
def dynamic_source_filename(self, filename, frame):
# TODO: Find calls to RequestValidator.validate
return None
def coverage_init(reg, options):
...
#+end_src

View file

@ -0,0 +1,5 @@
#+title: Tornado OpenAPI 3
#+roam_key: https://tornado-openapi3.readthedocs.io/
A library providing API specification validation to [[https://www.tornadoweb.org/][Tornado]] applications using
[[file:20210226114112-openapi_core.org][OpenAPI Core]].