1
0
mirror of https://codeberg.org/fediverse/fep.git synced 2026-08-05 11:46:04 +00:00
Files
fep/scripts/fep_tools/test_feps.py
T
Helge e4683fbcda Create a FEP static site (#673)
### Preview version

https://helge.codeberg.page/fep/

click there to judge

### Tasks done

- [x] Add a proper index.md instead of final.md .... needs me to filter the readme.md
- [x] search is broken  --> will resolve itself when all feps are part of it
- [x] Update https://codeberg.org/fediverse/fep/src/branch/main/fep/7d8c/fep-7d8c.md
- [x] The admonition format (according to copilot I can blame this format on Microsoft https://learn.microsoft.com/en-us/contribute/content/markdown-reference#alerts-note-important-tip-warning-caution)

    ```
    >[!NOTE]
    >ActivityPub [requires][ActivityPub-Collections] ordered collections to be presented in reverse chronological order. However, an [erratum][ActivityPub-Errata] was proposed to relax this requirement.
    ```
    is not the one supported by python, see https://python-markdown.github.io/extensions/admonition/ . One can probably resolve this by adapting the code https://github.com/Python-Markdown/markdown/blob/f39cf84a24124526c1a0efbe52219fa9950774f6/markdown/extensions/admonition.py

- [x] FEPs miss meta information ....
- [x] Meta information for tracking issue and discussion to link should be formatted
- [x] copy script has problems with contained directories
- [x] add codeberg link to meta, e.g. https://helge.codeberg.page/fep/fep/1b12/
- [x] include implementation counts -> https://codeberg.org/fediverse/fep/issues/686

Co-authored-by: silverpill <silverpill@firemail.cc>
Reviewed-on: https://codeberg.org/fediverse/fep/pulls/673
Reviewed-by: silverpill <silverpill@noreply.codeberg.org>
Co-authored-by: Helge <helge.krueger@gmail.com>
Co-committed-by: Helge <helge.krueger@gmail.com>
2025-11-01 08:40:20 +01:00

62 lines
1.8 KiB
Python

import datetime
import pytest
from urllib.parse import urlparse
from scripts.fep_tools import get_fep_ids, FepFile, title_to_slug
@pytest.mark.parametrize("fep", get_fep_ids())
def test_fep_front_matter(fep):
fep_file = FepFile(fep)
parsed_frontmatter = fep_file.parsed_frontmatter
assert "status" in parsed_frontmatter
assert parsed_frontmatter["status"] in ["DRAFT", "FINAL", "WITHDRAWN"]
assert parsed_frontmatter["slug"] == fep
assert "authors" in parsed_frontmatter
assert "dateReceived" in parsed_frontmatter
assert "discussionsTo" in parsed_frontmatter
discussions_to = parsed_frontmatter["discussionsTo"]
assert not urlparse(discussions_to).netloc.endswith(".example"), (
"Update discussionsTo to a valid URL for a discussion topic"
)
if parsed_frontmatter["status"] == "FINAL":
assert "dateFinalized" in parsed_frontmatter
if parsed_frontmatter["status"] == "WITHDRAWN":
assert "dateWithdrawn" in parsed_frontmatter
for field_name in ["dateReceived", "dateFinalized", "dateWithdrawn"]:
if field_name in parsed_frontmatter:
datetime.datetime.strptime(parsed_frontmatter[field_name], "%Y-%m-%d")
if "type" in parsed_frontmatter:
assert parsed_frontmatter["type"] in ["informational", "implementation"]
@pytest.mark.parametrize("fep", get_fep_ids())
def test_fep_content(fep):
fep_file = FepFile(fep)
content = fep_file.content
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 = title_to_slug(true_title)
assert expected_slug == fep