test(session): cover equivalent paths on Windows
This commit is contained in:
1 parent
db918bddd3
commit
7008473a3e
1 file changed
+17
-6
@@ -3,7 +3,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import uuid
|
import uuid
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
@@ -193,13 +195,22 @@ def test_equivalent_workspace_paths_share_one_store(tmp_path: Path) -> None:
|
|||||||
real_workspace = tmp_path / "real_ws"
|
real_workspace = tmp_path / "real_ws"
|
||||||
real_workspace.mkdir()
|
real_workspace.mkdir()
|
||||||
link_workspace = tmp_path / "link_ws"
|
link_workspace = tmp_path / "link_ws"
|
||||||
try:
|
if os.name == "nt":
|
||||||
link_workspace.symlink_to(real_workspace, target_is_directory=True)
|
completed = subprocess.run(
|
||||||
except OSError as exc:
|
["cmd", "/c", "mklink", "/J", str(link_workspace), str(real_workspace)],
|
||||||
# Creating directory symlinks needs admin/developer mode on Windows.
|
capture_output=True,
|
||||||
pytest.skip(f"directory symlink unavailable: {exc}")
|
text=True,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
if completed.returncode != 0:
|
||||||
|
pytest.skip(completed.stderr.strip() or completed.stdout.strip())
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
link_workspace.symlink_to(real_workspace, target_is_directory=True)
|
||||||
|
except OSError as exc:
|
||||||
|
pytest.skip(f"directory symlink unavailable: {exc}")
|
||||||
|
|
||||||
# Save via the real path, then read via a symlink to the same directory.
|
# Save via the real path, then read via an equivalent directory link.
|
||||||
manager = SessionManager(workspace=real_workspace)
|
manager = SessionManager(workspace=real_workspace)
|
||||||
session = manager.get_or_create("telegram:1")
|
session = manager.get_or_create("telegram:1")
|
||||||
session.add_message("user", "via-real")
|
session.add_message("user", "via-real")
|
||||||
|
|||||||
Reference in new issue
Block a user