1
0
mirror of https://github.com/enpaul/kodak.git synced 2024-11-23 15:07:13 +00:00
kodak/tests/test_openapi.py

25 lines
762 B
Python
Raw Normal View History

import importlib.resources
import openapi_spec_validator
import ruamel.yaml
2021-10-29 03:17:00 +00:00
from kodak import __about__
yaml = ruamel.yaml.YAML(typ="safe") # pylint: disable=invalid-name
def test_openapi():
"""Validate the OpenAPI specification document structure"""
openapi_spec_validator.validate_spec(
2021-10-29 03:17:00 +00:00
yaml.load(importlib.resources.read_text("kodak", "openapi.yaml"))
)
def test_openapi_version():
"""Check that the OpenAPI metadata matches the package metadata"""
2021-10-29 03:17:00 +00:00
spec = yaml.load(importlib.resources.read_text("kodak", "openapi.yaml"))
assert spec["info"]["version"] == __about__.__version__
assert spec["info"]["license"]["name"] == __about__.__license__
assert spec["info"]["title"].lower() == __about__.__title__.lower()