@@ -32,32 +32,47 @@ def test_respects_basic_memory_home_environment_variable(self, config_home, monk
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 , config_home , monkeypatch ):
36- """Test that model_post_init creates main project with BASIC_MEMORY_HOME when missing."""
35+ def test_model_post_init_respects_basic_memory_home_creates_main (
36+ self , config_home , monkeypatch
37+ ):
38+ """Test that model_post_init creates main project with BASIC_MEMORY_HOME when missing and no other projects."""
3739 custom_path = str (config_home / "custom" / "memory" / "path" )
3840 monkeypatch .setenv ("BASIC_MEMORY_HOME" , custom_path )
3941
4042 # Create config without main project
41- other_path = str (config_home / "some" / "path" )
42- config = BasicMemoryConfig (projects = {"other" : other_path })
43+ config = BasicMemoryConfig ()
4344
4445 # model_post_init should have added main project with BASIC_MEMORY_HOME
4546 assert "main" in config .projects
4647 assert config .projects ["main" ] == Path (custom_path ).as_posix ()
4748
49+ def test_model_post_init_respects_basic_memory_home_sets_non_main_default (
50+ self , config_home , monkeypatch
51+ ):
52+ """Test that model_post_init does not create main project with BASIC_MEMORY_HOME when another project exists."""
53+ custom_path = str (config_home / "custom" / "memory" / "path" )
54+ monkeypatch .setenv ("BASIC_MEMORY_HOME" , custom_path )
55+
56+ # Create config without main project
57+ other_path = str (config_home / "some" / "path" )
58+ config = BasicMemoryConfig (projects = {"other" : Path (other_path ).as_posix ()})
59+
60+ # model_post_init should not add main project with BASIC_MEMORY_HOME
61+ assert "main" not in config .projects
62+ assert config .projects ["other" ] == Path (other_path ).as_posix ()
63+
4864 def test_model_post_init_fallback_without_basic_memory_home (self , config_home , monkeypatch ):
49- """Test that model_post_init falls back to default when BASIC_MEMORY_HOME is not set."""
65+ """Test that model_post_init can set a non-main default when BASIC_MEMORY_HOME is not set."""
5066 # Ensure BASIC_MEMORY_HOME is not set
5167 monkeypatch .delenv ("BASIC_MEMORY_HOME" , raising = False )
5268
5369 # Create config without main project
5470 other_path = (config_home / "some" / "path" ).as_posix ()
5571 config = BasicMemoryConfig (projects = {"other" : other_path })
5672
57- # model_post_init should have added main project with default path
58- expected_path = (config_home / "basic-memory" ).as_posix ()
59- assert "main" in config .projects
60- assert config .projects ["main" ] == Path (expected_path ).as_posix ()
73+ # model_post_init should not add main project, but "other" should now be the default
74+ assert "main" not in config .projects
75+ assert config .projects ["other" ] == Path (other_path ).as_posix ()
6176
6277 def test_basic_memory_home_with_relative_path (self , config_home , monkeypatch ):
6378 """Test that BASIC_MEMORY_HOME works with relative paths."""
0 commit comments