okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
2b36e8a02
main
1"""The local link check (tools/check_links.py) and the pointer files left where material moved to history/.""" 2import os 3import sys 4import unittest 5 6sys .path .insert (0 ,os .path .dirname (os .path .abspath (__file__ ))) 7import check_links as cl # noqa: E402 8import doc_pages # noqa: E402 9 10 11class LinkCheck (unittest .TestCase ): 12def test_current_pages_have_no_broken_local_links (self ): 13problems = [] 14for page in doc_pages .current_pages (): 15problems += cl .check_page (page ,want_anchors = True ) 16self .assertEqual (problems , [],"\n" .join ("%s:%d %s (%s)" % (p ,n ,t ,w )for p ,n ,t ,w in problems )) 17 18def test_links_in_code_and_comments_are_not_checked (self ): 19text = "[a](real.md) `[b](code.md)`\n```\n[c](fence.md)\n```\n<!-- [d](comment.md) -->\n[e](https://example.com/x.md) [f](#top) [g](other.md#h)\n" 20self .assertEqual ([t for _ ,t in cl .targets (text )], ["real.md" ,"https://example.com/x.md" ,"#top" ,"other.md#h" ]) 21 22def test_a_missing_target_is_reported_and_urls_are_not_local (self ): 23self .assertIsNone (cl .resolve ("docs/README.md" ,"https://github.com/Niko1221/Strata" )) 24self .assertIsNone (cl .resolve ("docs/README.md" ,"mailto:a@b.c" )) 25self .assertTrue (cl .resolve ("docs/README.md" ,"INSTALL.md" ).endswith (os .path .join ("docs" ,"INSTALL.md" ))) 26self .assertTrue (cl .resolve ("docs/README.md" ,"/LICENSE" ).endswith ("LICENSE" )) 27 28def test_every_pointer_resolves_into_history (self ): 29pointers = ["apps/host/audit-fixes/README.md" ,"docs/work/README.md" ,"packaging/acceptance_matrix.md" , 30"apps/host/docs/persona-review-2026-10-05/README.md" ,"apps/host/docs/plans/README.md" ,"apps/host/docs/README.md" ] 31for page in pointers : 32self .assertEqual (cl .check_page (page ,want_anchors = True ), [],page ) 33text = open (os .path .join (doc_pages .ROOT ,page ),encoding = "utf-8" ).read () 34self .assertIn ("history" ,text ,page ) 35 36 37if __name__ == "__main__" : 38unittest .main ()