Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mkdocs_monorepo_plugin/edit_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def __is_root(self):
abs_root_config_file_dir, root_config_docs_dir
)

return path.realpath(abs_root_config_docs_dir) in self.page.file.abs_src_path
return path.realpath(abs_root_config_docs_dir) in path.realpath(
self.page.file.abs_src_path
)

def build(self):
if self.__is_root():
Expand Down
30 changes: 30 additions & 0 deletions mkdocs_monorepo_plugin/tests/test_edit_uri.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python

from types import SimpleNamespace
from unittest import TestCase
from unittest.mock import patch

from mkdocs_monorepo_plugin.edit_uri import EditUrl


class TestEditUri(TestCase):
def test_is_root_uses_realpath_for_page_source_path(self):
config = {"config_file_path": "/var/folders/work/mkdocs.yml"}
page = SimpleNamespace(
file=SimpleNamespace(abs_src_path="/var/folders/work/docs/index.md")
)
plugin = SimpleNamespace(originalDocsDir="/var/folders/work/docs")

edit_url = EditUrl(config, page, plugin)

def fake_realpath(value):
if value.startswith("/var/folders/work"):
return value.replace(
"/var/folders/work", "/private/var/folders/work", 1
)
return value

with patch(
"mkdocs_monorepo_plugin.edit_uri.path.realpath", side_effect=fake_realpath
):
self.assertTrue(edit_url._EditUrl__is_root())