1
0
mirror of https://codeberg.org/fediverse/fep.git synced 2026-08-05 19:55:46 +00:00
Files
fep/scripts/fep_tools/test_site_fep_page.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

72 lines
2.0 KiB
Python

import pytest
from . import fep_file
from .site_fep_page import format_metatable, clean_markdown, transform_content
def skip_due_to_no_nh3_markdown():
try:
import nh3 # type: ignore # noqa
import markdown # type: ignore # noqa
except Exception:
return True
return False
def test_format_metatable():
file = fep_file.FepFile("a4ed")
table = format_metatable(file)
assert (
table
== """
| Authors | Status | Date received | Date final | Tracking issue | Discussions | Repository |
| --- | --- | --- | --- | --- | --- | --- |
| pukkamustard <pukkamustard@posteo.net> | `FINAL` | 2020-10-16 | 2021-01-18 | [#201](https://codeberg.org/fediverse/fep/issues/201) | - | [codeberg](https://codeberg.org/fediverse/fep/src/branch/main/fep/a4ed/fep-a4ed.md) |
"""
)
@pytest.mark.skipif(
skip_due_to_no_nh3_markdown(), reason="nh3 and markdown not installed"
)
@pytest.mark.parametrize(
"text,expected",
[
("[link](http://test.example)", "link"),
("[link][link]", "link"),
("[a][a] [b][b]", "a b"),
("a:b", "a b"),
],
)
def test_clean_markdown(text: str, expected: str):
result = clean_markdown(text)
assert result == expected
@pytest.mark.skipif(
skip_due_to_no_nh3_markdown(), reason="nh3 and markdown not installed"
)
@pytest.mark.parametrize(
"unchanged",
[
"[link](http://remote.tests)",
"[fep-f1d5](https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md)",
"[fep-f1d5]: https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md",
],
)
def test_content_unchanged(unchanged: str):
assert transform_content(unchanged) == unchanged
@pytest.mark.skipif(
skip_due_to_no_nh3_markdown(), reason="nh3 and markdown not installed"
)
def test_content():
changed = "[link](../4adb/fep-4adb.md)"
assert transform_content(changed) == "[link](../4adb/index.md)"
changed = "[FEP-4adb]: ../4adb/fep-4adb.md"
assert transform_content(changed) == "[FEP-4adb]: ../4adb/index.md"