import json from pathlib import Path from generate_openapi import generate_openapi DIR_PROJECT_ROOT = Path(__file__).parent.parent DIR_TESTDATA = Path(__file__).parent / "testdata" def test_openapi_spec_current(): """Verify the openapi spec hasn“t changed.""" old_spec_path = DIR_PROJECT_ROOT / "docs" / "akkudoktoreos" / "openapi.json" new_spec_path = DIR_TESTDATA / "openapi-new.json" generate_openapi(new_spec_path) with open(new_spec_path) as f_new: new_spec = json.load(f_new) with open(old_spec_path) as f_old: old_spec = json.load(f_old) # Serialize to ensure comparison is consistent new_spec = json.dumps(new_spec, indent=4, sort_keys=True) old_spec = json.dumps(old_spec, indent=4, sort_keys=True) assert new_spec == old_spec