mirror of
https://codeberg.org/fediverse/fep.git
synced 2026-08-05 11:46:04 +00:00
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import pytest
|
|
import hashlib
|
|
|
|
from scripts.tools import get_fep_ids, FepFile
|
|
|
|
|
|
@pytest.mark.parametrize("fep", get_fep_ids())
|
|
def test_fep(fep):
|
|
fep_file = FepFile(fep)
|
|
|
|
content = fep_file.content
|
|
parsed_frontmatter = fep_file.parsed_frontmatter
|
|
|
|
assert "status" in parsed_frontmatter
|
|
assert parsed_frontmatter["status"] in ["DRAFT", "FINAL", "WITHDRAWN"]
|
|
assert parsed_frontmatter["slug"] == f'"{fep}"'
|
|
assert "authors" in parsed_frontmatter
|
|
|
|
if parsed_frontmatter["status"] == "FINAL":
|
|
assert "dateFinalized" in parsed_frontmatter
|
|
if parsed_frontmatter["status"] == "WITHDRAWN":
|
|
assert "dateWithdrawn" in parsed_frontmatter
|
|
|
|
assert "## Summary" in content
|
|
assert "## Copyright" in content
|
|
|
|
titles = [x for x in content if x.startswith("# ")]
|
|
assert len(titles) > 0
|
|
|
|
title = titles[0]
|
|
|
|
begin_title = f"# FEP-{fep}: "
|
|
|
|
assert title.startswith(begin_title)
|
|
true_title = title.removeprefix(begin_title)
|
|
|
|
expected_slug = hashlib.sha256(true_title.encode("utf-8")).hexdigest()[:4]
|
|
|
|
assert expected_slug == fep
|