@@ -101,6 +101,41 @@ def test_profile_save_load_remove(self):
101101 # remove the profile
102102 tiledb .Profile .remove ("profile2_name" , self .path ("profile2_dir" ))
103103
104+ @pytest .mark .skipif (
105+ lt .version () < (2 , 30 ),
106+ reason = "Overwrite parameter is only available in TileDB 2.30.0 and later" ,
107+ )
108+ def test_profile_save_overwrite (self ):
109+ token1 = "testing_the_token_1"
110+ token2 = "testing_the_token_2"
111+ profile_name = "overwrite_test_profile"
112+ profile_dir = self .path ("overwrite_test_dir" )
113+
114+ # Create and save a profile with token1
115+ profile1 = tiledb .Profile (profile_name , profile_dir )
116+ profile1 ["rest.token" ] = token1
117+ profile1 .save ()
118+
119+ # Load it back to verify it was saved
120+ loaded_profile1 = tiledb .Profile .load (profile_name , profile_dir )
121+ assert loaded_profile1 ["rest.token" ] == token1
122+
123+ # Create a new profile with the same name and try to save without overwrite
124+ profile2 = tiledb .Profile (profile_name , profile_dir )
125+ profile2 ["rest.token" ] = token2
126+ with pytest .raises (tiledb .TileDBError ):
127+ profile2 .save (overwrite = False )
128+
129+ # Now save with overwrite=True
130+ profile2 .save (overwrite = True )
131+
132+ # Load it back to verify it was overwritten
133+ loaded_profile2 = tiledb .Profile .load (profile_name , profile_dir )
134+ assert loaded_profile2 ["rest.token" ] == token2
135+
136+ # Clean up
137+ tiledb .Profile .remove (profile_name , profile_dir )
138+
104139
105140class ConfigWithProfileTest (ProfileTestCase ):
106141 def test_config_with_profile (self ):
0 commit comments