-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test dependencies and document how to install and run tests * Add regression tests for different types of links * Fix #11 properly: Test for `#` prefix in links * Rolls back the broken fix in 8d4b5ee *Fixes #11 by checking for a hash prefix in closure code
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 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
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Jinja2==3.1.2 | ||
requests==2.31.0 | ||
pytest[test]==7.4.3 | ||
mkdocs[test]==1.5.3 |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
|
||
from external_markdown.plugin import EmbedExternalMarkdown | ||
|
||
BASE_URL = "https://BASEURL/" | ||
BASE_FILE = "https://BASEURL/FILE.md" | ||
TEST_DATA = [ | ||
( | ||
"external link", | ||
"https://github.com", | ||
"https://github.com"), | ||
( | ||
"external link with anchor", | ||
"https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_variables.html#using-variables-about-jinja2", | ||
"https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_variables.html#using-variables-about-jinja2", | ||
), | ||
( | ||
"anchor", | ||
"#links", | ||
"#links"), | ||
( | ||
"local link", | ||
"page.md", | ||
f"{BASE_URL}page.md"), | ||
( | ||
"local link with anchor", | ||
"page.md#test-subsection", | ||
f"{BASE_URL}page.md#test-subsection", | ||
), | ||
] | ||
|
||
|
||
class TestEmbedExternalMarkdown: | ||
@pytest.mark.parametrize("label,link_url,expected_url", TEST_DATA) | ||
def test_update_relative_links_external(self, label, link_url, expected_url): | ||
# Regression tests for #11 | ||
link = f"[{label}]({link_url})" | ||
expected = f"[{label}]({expected_url})" | ||
assert EmbedExternalMarkdown().update_relative_links(link, BASE_FILE) == expected |