38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
# retoor <retoor@molodetz.nl>
|
|||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from devplacepy.docs_api import API_GROUPS
|
||
|
|
|
||
|
|
ENDPOINTS = {e["id"]: e for g in API_GROUPS for e in g["endpoints"]}
|
||
|
|
WRITES = ("posts-create", "posts-edit", "gists-create", "gists-edit", "projects-create", "projects-edit")
|
||
|
|
|
||
|
|
|
||
|
|
def _field(endpoint_id):
|
||
|
|
return next(p for p in ENDPOINTS[endpoint_id]["params"] if p["name"] == "visibility")
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("endpoint_id", WRITES)
|
||
|
|
def test_visibility_is_documented_optional_and_enumerated(endpoint_id):
|
||
|
|
field = _field(endpoint_id)
|
||
|
|
assert field["required"] is False
|
||
|
|
assert field["location"] == "form"
|
||
|
|
assert field["options"] == ["published", "hidden", "offline", "draft"]
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("endpoint_id", ("posts-create", "gists-create", "projects-create"))
|
||
|
|
def test_create_docs_state_the_default(endpoint_id):
|
||
|
|
assert "published" in _field(endpoint_id)["description"]
|
||
|
|
assert "when omitted the item is published" in _field(endpoint_id)["description"]
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("endpoint_id", ("posts-edit", "gists-edit", "projects-edit"))
|
||
|
|
def test_edit_docs_state_that_omitting_keeps_the_value(endpoint_id):
|
||
|
|
assert "when omitted the current value is kept" in _field(endpoint_id)["description"]
|
||
|
|
|
||
|
|
|
||
|
|
def test_admin_news_visibility_endpoint_is_documented_as_admin_only():
|
||
|
|
endpoint = ENDPOINTS["admin-news-visibility"]
|
||
|
|
assert endpoint["auth"] == "admin"
|
||
|
|
assert any(p["name"] == "value" and p["required"] for p in endpoint["params"])
|