fix: Dump media handlers and timezones with --dump-schema

Those were left out of the schema dump when the features were introduced, probably
because ByteString doesn't have a toJSON instance. Changing the type to Text solves
this easily.

Resolves #3237
This commit is contained in:
Wolfgang Walther
2024-02-20 18:44:17 +01:00
committed by Wolfgang Walther
parent 6d506df6f3
commit 8a21a9c34e
9 changed files with 1803 additions and 14 deletions
+19
View File
@@ -21,11 +21,21 @@ import jwt
import pytest
import requests
import requests_unixsocket
from syrupy.extensions.json import SingleFileSnapshotExtension
import yaml
from config import *
class YamlSnapshotExtension(SingleFileSnapshotExtension):
_file_extension = "yaml"
@pytest.fixture
def snapshot_yaml(snapshot):
return snapshot.use_extension(YamlSnapshotExtension)
def itemgetter(*items):
"operator.itemgetter with None as fallback when key does not exist"
if len(items) == 1:
@@ -225,3 +235,12 @@ def test_invalid_openapi_mode(invalidopenapimodes, defaultenv):
for line in dump.split("\n"):
if line.startswith("openapi-mode"):
print(line)
# If this test is failing, run pytest with --snapshot-update.
def test_schema_cache_snapshot(baseenv, snapshot_yaml):
"Dump of schema cache should match snapshot."
schema_cache = yaml.load(cli(["--dump-schema"], env=baseenv), Loader=yaml.Loader)
formatted = yaml.dump(schema_cache, encoding="utf8", allow_unicode=True)
assert formatted == snapshot_yaml