Files
devplacepy/tests/unit/docs_api/_shared.py
T

37 lines
1.0 KiB
Python
Raw Normal View History

from devplacepy.docs_api import field, endpoint
def test_field_defaults_nullable_false():
spec = field("username", "path", "string", True, "alice", "A username.")
assert spec["nullable"] is False
def test_field_nullable_true_is_threaded_into_spec():
spec = field(
"avatar_seed",
"response",
"string",
description="Null falls back to the username.",
nullable=True,
)
assert spec["nullable"] is True
assert spec["location"] == "response"
def test_endpoint_carries_response_field_specs_in_params():
ep = endpoint(
id="example",
method="GET",
path="/example",
title="Example",
summary="An example endpoint.",
auth="public",
params=[
field("uid", "response", "string", nullable=False),
field("bio", "response", "string", nullable=True),
],
)
by_name = {p["name"]: p for p in ep["params"]}
assert by_name["uid"]["nullable"] is False
assert by_name["bio"]["nullable"] is True