2023-10-07 15:06:24 +00:00
|
|
|
import datetime
|
2023-07-16 07:43:02 +00:00
|
|
|
import pytest
|
|
|
|
|
|
2025-01-20 10:24:00 +00:00
|
|
|
from urllib.parse import urlparse
|
|
|
|
|
|
2023-10-23 14:35:30 +00:00
|
|
|
from scripts.tools import get_fep_ids, FepFile, title_to_slug
|
2023-07-16 07:43:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("fep", get_fep_ids())
|
2025-01-20 10:24:00 +00:00
|
|
|
def test_fep_front_matter(fep):
|
2023-07-16 07:43:02 +00:00
|
|
|
fep_file = FepFile(fep)
|
|
|
|
|
parsed_frontmatter = fep_file.parsed_frontmatter
|
|
|
|
|
|
|
|
|
|
assert "status" in parsed_frontmatter
|
2023-09-04 18:13:10 +00:00
|
|
|
assert parsed_frontmatter["status"] in ["DRAFT", "FINAL", "WITHDRAWN"]
|
2024-12-16 08:40:56 +00:00
|
|
|
assert parsed_frontmatter["slug"] == fep
|
2023-07-16 07:43:02 +00:00
|
|
|
assert "authors" in parsed_frontmatter
|
2024-07-30 02:42:37 +00:00
|
|
|
assert "dateReceived" in parsed_frontmatter
|
2024-08-10 09:39:38 +00:00
|
|
|
assert "discussionsTo" in parsed_frontmatter
|
2023-07-16 07:43:02 +00:00
|
|
|
|
2025-01-20 10:24:00 +00:00
|
|
|
discussions_to = parsed_frontmatter["discussionsTo"]
|
|
|
|
|
|
|
|
|
|
assert not urlparse(discussions_to).netloc.endswith(
|
|
|
|
|
".example"
|
|
|
|
|
), "Update discussionsTo to a valid URL for a discussion topic"
|
|
|
|
|
|
2023-09-06 19:44:58 +02:00
|
|
|
if parsed_frontmatter["status"] == "FINAL":
|
|
|
|
|
assert "dateFinalized" in parsed_frontmatter
|
|
|
|
|
if parsed_frontmatter["status"] == "WITHDRAWN":
|
|
|
|
|
assert "dateWithdrawn" in parsed_frontmatter
|
|
|
|
|
|
2023-10-07 15:06:24 +00:00
|
|
|
for field_name in ["dateReceived", "dateFinalized", "dateWithdrawn"]:
|
|
|
|
|
if field_name in parsed_frontmatter:
|
2023-10-23 14:35:30 +00:00
|
|
|
datetime.datetime.strptime(parsed_frontmatter[field_name], "%Y-%m-%d")
|
2023-10-07 15:06:24 +00:00
|
|
|
|
2025-01-20 10:24:00 +00:00
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("fep", get_fep_ids())
|
|
|
|
|
def test_fep_content(fep):
|
|
|
|
|
fep_file = FepFile(fep)
|
|
|
|
|
|
|
|
|
|
content = fep_file.content
|
|
|
|
|
|
2023-07-16 07:43:02 +00:00
|
|
|
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)
|
|
|
|
|
|
2023-10-23 14:35:30 +00:00
|
|
|
expected_slug = title_to_slug(true_title)
|
2023-07-16 07:43:02 +00:00
|
|
|
|
|
|
|
|
assert expected_slug == fep
|