Skip to content

Commit 7c2cf3c

Browse files
committed
Fixed more WindowsPath issues mostly in assertions of unit tests
Signed-off-by: Manuel Bliemel <manuel.bliemel@gmail.com>
1 parent 465d4a2 commit 7c2cf3c

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/basic_memory/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def model_post_init(self, __context: Any) -> None:
100100
"""Ensure configuration is valid after initialization."""
101101
# Ensure main project exists
102102
if "main" not in self.projects: # pragma: no cover
103-
self.projects["main"] = str(
103+
self.projects["main"] = (
104104
Path(os.getenv("BASIC_MEMORY_HOME", Path.home() / "basic-memory"))
105-
)
105+
).as_posix()
106106

107107
# Ensure default project is valid
108108
if self.default_project not in self.projects: # pragma: no cover

tests/api/test_project_router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ async def test_update_project_both_params_endpoint(
256256
"""Test the update project endpoint with both path and is_active parameters."""
257257
# Create a test project to update
258258
test_project_name = "test-update-both-project"
259-
old_path = str(tmp_path / "old-location")
260-
new_path = str(tmp_path / "new-location")
259+
old_path = (tmp_path / "old-location").as_posix()
260+
new_path = (tmp_path / "new-location").as_posix()
261261

262262
await project_service.add_project(test_project_name, old_path)
263263

tests/services/test_project_service.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for ProjectService."""
22

33
import os
4+
from pathlib import Path
45

56
import pytest
67

@@ -73,7 +74,7 @@ async def test_project_operations_sync_methods(
7374
"""
7475
# Generate a unique project name for testing
7576
test_project_name = f"test-project-{os.urandom(4).hex()}"
76-
test_project_path = str(tmp_path / "test-project")
77+
test_project_path = (tmp_path / "test-project").as_posix()
7778

7879
# Make sure the test directory exists
7980
os.makedirs(test_project_path, exist_ok=True)
@@ -590,8 +591,8 @@ async def test_move_project_nonexistent(project_service: ProjectService, tmp_pat
590591
async def test_move_project_db_mismatch(project_service: ProjectService, tmp_path):
591592
"""Test moving a project that exists in config but not in database."""
592593
test_project_name = f"test-move-mismatch-{os.urandom(4).hex()}"
593-
old_path = str(tmp_path / "old-location")
594-
new_path = str(tmp_path / "new-location")
594+
old_path = (tmp_path / "old-location").as_posix()
595+
new_path = (tmp_path / "new-location").as_posix()
595596

596597
# Create directories
597598
os.makedirs(old_path, exist_ok=True)
@@ -624,7 +625,7 @@ async def test_move_project_db_mismatch(project_service: ProjectService, tmp_pat
624625
async def test_move_project_expands_path(project_service: ProjectService, tmp_path):
625626
"""Test that move_project expands ~ and relative paths."""
626627
test_project_name = f"test-move-expand-{os.urandom(4).hex()}"
627-
old_path = str(tmp_path / "old-location")
628+
old_path = (tmp_path / "old-location").as_posix()
628629

629630
# Create old directory
630631
os.makedirs(old_path, exist_ok=True)
@@ -635,7 +636,7 @@ async def test_move_project_expands_path(project_service: ProjectService, tmp_pa
635636

636637
# Use a relative path for the move
637638
relative_new_path = "./new-location"
638-
expected_absolute_path = os.path.abspath(relative_new_path)
639+
expected_absolute_path = Path(os.path.abspath(relative_new_path)).as_posix()
639640

640641
# Move project using relative path
641642
await project_service.move_project(test_project_name, relative_new_path)

tests/services/test_project_service_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def test_add_project_to_config(project_service: ProjectService, tmp_path,
4848
"""Test adding a project to the config manager."""
4949
# Generate unique project name for testing
5050
test_project_name = f"config-project-{os.urandom(4).hex()}"
51-
test_path = str(tmp_path / "config-project")
51+
test_path = (tmp_path / "config-project").as_posix()
5252

5353
# Make sure directory exists
5454
os.makedirs(test_path, exist_ok=True)

tests/test_config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Test configuration management."""
22

3-
from pathlib import Path
43
from basic_memory.config import BasicMemoryConfig
54

65

@@ -15,7 +14,7 @@ def test_default_behavior_without_basic_memory_home(self, config_home, monkeypat
1514
config = BasicMemoryConfig()
1615

1716
# Should use the default path (home/basic-memory)
18-
expected_path = Path(config_home / "basic-memory").as_posix()
17+
expected_path = (config_home / "basic-memory").as_posix()
1918
assert config.projects["main"] == expected_path
2019

2120
def test_respects_basic_memory_home_environment_variable(self, config_home, monkeypatch):
@@ -47,7 +46,7 @@ def test_model_post_init_fallback_without_basic_memory_home(self, config_home, m
4746
monkeypatch.delenv("BASIC_MEMORY_HOME", raising=False)
4847

4948
# Create config without main project
50-
other_path = Path(config_home / "some" / "path").as_posix()
49+
other_path = (config_home / "some" / "path").as_posix()
5150
config = BasicMemoryConfig(projects={"other": other_path})
5251

5352
# model_post_init should have added main project with default path

0 commit comments

Comments
 (0)