Skip to content

Commit 7191fbd

Browse files
claude[bot]groksrc
andauthored
fix: use config_home fixture in BASIC_MEMORY_HOME tests to resolve CI permission issues
- Replace Path.home() with config_home fixture for temporary directories - Use paths within test directory instead of hardcoded absolute paths - Follow existing test patterns from conftest.py for proper CI compatibility - Maintain all original test coverage while fixing permission issues Co-authored-by: Drew Cain <groksrc@users.noreply.github.com>
1 parent f8fd74a commit 7191fbd

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

tests/test_config.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,55 @@
1111
class TestBasicMemoryConfig:
1212
"""Test BasicMemoryConfig behavior with BASIC_MEMORY_HOME environment variable."""
1313

14-
def test_default_behavior_without_basic_memory_home(self, monkeypatch):
14+
def test_default_behavior_without_basic_memory_home(self, config_home, monkeypatch):
1515
"""Test that config uses default path when BASIC_MEMORY_HOME is not set."""
1616
# Ensure BASIC_MEMORY_HOME is not set
1717
monkeypatch.delenv("BASIC_MEMORY_HOME", raising=False)
1818

1919
config = BasicMemoryConfig()
2020

2121
# Should use the default path (home/basic-memory)
22-
expected_path = str(Path.home() / "basic-memory")
22+
expected_path = str(config_home / "basic-memory")
2323
assert config.projects["main"] == expected_path
2424

25-
def test_respects_basic_memory_home_environment_variable(self, monkeypatch):
25+
def test_respects_basic_memory_home_environment_variable(self, config_home, monkeypatch):
2626
"""Test that config respects BASIC_MEMORY_HOME environment variable."""
27-
custom_path = "/app/data"
27+
custom_path = str(config_home / "app" / "data")
2828
monkeypatch.setenv("BASIC_MEMORY_HOME", custom_path)
2929

3030
config = BasicMemoryConfig()
3131

3232
# Should use the custom path from environment variable
3333
assert config.projects["main"] == custom_path
3434

35-
def test_model_post_init_respects_basic_memory_home(self, monkeypatch):
35+
def test_model_post_init_respects_basic_memory_home(self, config_home, monkeypatch):
3636
"""Test that model_post_init creates main project with BASIC_MEMORY_HOME when missing."""
37-
custom_path = "/custom/memory/path"
37+
custom_path = str(config_home / "custom" / "memory" / "path")
3838
monkeypatch.setenv("BASIC_MEMORY_HOME", custom_path)
3939

4040
# Create config without main project
41-
config = BasicMemoryConfig(projects={"other": "/some/path"})
41+
other_path = str(config_home / "some" / "path")
42+
config = BasicMemoryConfig(projects={"other": other_path})
4243

4344
# model_post_init should have added main project with BASIC_MEMORY_HOME
4445
assert "main" in config.projects
4546
assert config.projects["main"] == custom_path
4647

47-
def test_model_post_init_fallback_without_basic_memory_home(self, monkeypatch):
48+
def test_model_post_init_fallback_without_basic_memory_home(self, config_home, monkeypatch):
4849
"""Test that model_post_init falls back to default when BASIC_MEMORY_HOME is not set."""
4950
# Ensure BASIC_MEMORY_HOME is not set
5051
monkeypatch.delenv("BASIC_MEMORY_HOME", raising=False)
5152

5253
# Create config without main project
53-
config = BasicMemoryConfig(projects={"other": "/some/path"})
54+
other_path = str(config_home / "some" / "path")
55+
config = BasicMemoryConfig(projects={"other": other_path})
5456

5557
# model_post_init should have added main project with default path
56-
expected_path = str(Path.home() / "basic-memory")
58+
expected_path = str(config_home / "basic-memory")
5759
assert "main" in config.projects
5860
assert config.projects["main"] == expected_path
5961

60-
def test_basic_memory_home_with_relative_path(self, monkeypatch):
62+
def test_basic_memory_home_with_relative_path(self, config_home, monkeypatch):
6163
"""Test that BASIC_MEMORY_HOME works with relative paths."""
6264
relative_path = "relative/memory/path"
6365
monkeypatch.setenv("BASIC_MEMORY_HOME", relative_path)
@@ -67,13 +69,14 @@ def test_basic_memory_home_with_relative_path(self, monkeypatch):
6769
# Should use the exact value from environment variable
6870
assert config.projects["main"] == relative_path
6971

70-
def test_basic_memory_home_overrides_existing_main_project(self, monkeypatch):
72+
def test_basic_memory_home_overrides_existing_main_project(self, config_home, monkeypatch):
7173
"""Test that BASIC_MEMORY_HOME is used even when main project exists in constructor."""
72-
custom_path = "/override/memory/path"
74+
custom_path = str(config_home / "override" / "memory" / "path")
7375
monkeypatch.setenv("BASIC_MEMORY_HOME", custom_path)
7476

7577
# Try to create config with a different main project path
76-
config = BasicMemoryConfig(projects={"main": "/original/path"})
78+
original_path = str(config_home / "original" / "path")
79+
config = BasicMemoryConfig(projects={"main": original_path})
7780

7881
# The default_factory should override with BASIC_MEMORY_HOME value
7982
# Note: This tests the current behavior where default_factory takes precedence

0 commit comments

Comments
 (0)