-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: External markdowns are treated as internal links (#12)
- Loading branch information
1 parent
6a6bfeb
commit c9eaf7c
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import tempfile | ||
import threading | ||
import unittest | ||
from pathlib import Path | ||
|
||
from tools.github_readme_sync.hierarchy import ( | ||
CATEGORY_PREFIX, | ||
|
@@ -21,6 +22,7 @@ | |
INDENTATION_UNIT, | ||
check_external, | ||
check_hierarchy_file, | ||
check_links, | ||
create_hierarchy_file, | ||
extract_links, | ||
) | ||
|
@@ -233,6 +235,21 @@ def extract(input_string, expected_output): | |
["https://a.com/quotes"], | ||
) | ||
|
||
def test_check_links_ignores_external(self): | ||
"""Test that check_links ignores external links (http/https/mailto).""" | ||
with tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False) as f: | ||
f.write(""" | ||
[External Link](https://example.com/page.md) | ||
[Another External](http://test.com/doc.md) | ||
[Email Link](mailto:[email protected]) | ||
""") | ||
temp_path = f.name | ||
|
||
try: | ||
self.assertEqual(check_links(temp_path), []) | ||
finally: | ||
Path(temp_path).unlink() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |