1
0
mirror of https://codeberg.org/fediverse/fep.git synced 2026-08-05 11:46:04 +00:00
Files
fep/scripts/tools/test_feps.py
T
Helge 854ef33092 Automate creating readme and tracking issue (#460)
Note at @fediverse/FEP-Editors

- Once this is merged please check it does the right thing.
- If you are ok with automating these things, I'll update the description of a facilitators role to just be checking and mergin
- finally, can we rename the codeberg group, I just addressed, to FEP-Facilitators

Final note: I already configured Woodpecker and the repository. This is to ensure that merging this pull request does not lead to a broken CI, second I might forget the steps ...

- [x] Force myself to document the automated process as a FEP

Reviewed-on: https://codeberg.org/fediverse/fep/pulls/460
Reviewed-by: silverpill <silverpill@noreply.codeberg.org>
Co-authored-by: Helge <helge.krueger@gmail.com>
Co-committed-by: Helge <helge.krueger@gmail.com>
2025-01-20 10:24:00 +00:00

59 lines
1.7 KiB
Python

import datetime
import pytest
from urllib.parse import urlparse
from scripts.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")
@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