1818from ravendb .documents .operations .connection_string .put_connection_string_operation import (
1919 PutConnectionStringOperation ,
2020)
21+ from ravendb .documents .operations .connection_string .remove_connection_string_by_name_operation import (
22+ RemoveConnectionStringByNameOperation ,
23+ )
2124from ravendb .documents .operations .connection_string .remove_connection_string_operation import (
2225 RemoveConnectionStringOperation ,
2326)
@@ -83,9 +86,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
8386 self .assertEqual (1 , len (raven_get_result .raven_connection_strings ))
8487
8588 # 3. Delete
86- remove_result = self .store .maintenance .send (
87- RemoveConnectionStringOperation ("raven1" , ConnectionStringType .RAVEN )
88- )
89+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (raven_connection_string ))
8990 self .assertGreater (remove_result .raft_command_index , 0 )
9091
9192 # 4. Get and Assert None
@@ -103,7 +104,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
103104 self .assertEqual (1 , len (sql_get_result .sql_connection_strings ))
104105
105106 # 3. Delete
106- remove_result = self .store .maintenance .send (RemoveConnectionStringOperation ("sql1" , ConnectionStringType . SQL ))
107+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (sql_connection_string ))
107108 self .assertGreater (remove_result .raft_command_index , 0 )
108109
109110 # 4. Get and Assert None
@@ -121,7 +122,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
121122 self .assertEqual (1 , len (olap_get_result .olap_connection_strings ))
122123
123124 # 3. Delete
124- remove_result = self .store .maintenance .send (RemoveConnectionStringOperation ("olap1" , ConnectionStringType . OLAP ))
125+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (olap_connection_string ))
125126 self .assertGreater (remove_result .raft_command_index , 0 )
126127
127128 # 4. Get and Assert None
@@ -140,9 +141,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
140141 self .assertEqual (1 , len (elastic_get_result .elastic_search_connection_strings ))
141142
142143 # 3. Delete
143- remove_result = self .store .maintenance .send (
144- RemoveConnectionStringOperation ("elastic1" , ConnectionStringType .ELASTIC_SEARCH )
145- )
144+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (elastic_search_connection_string ))
146145 self .assertGreater (remove_result .raft_command_index , 0 )
147146
148147 # 4. Get and Assert None
@@ -164,9 +163,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
164163 self .assertEqual (1 , len (queue_get_result .queue_connection_strings ))
165164
166165 # 3. Delete
167- remove_result = self .store .maintenance .send (
168- RemoveConnectionStringOperation ("queue1" , ConnectionStringType .QUEUE )
169- )
166+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (queue_connection_string ))
170167 self .assertGreater (remove_result .raft_command_index , 0 )
171168
172169 # 4. Get and Assert None
@@ -186,9 +183,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
186183 self .assertEqual (1 , len (snowflake_get_result .snowflake_connection_strings ))
187184
188185 # 3. Delete
189- remove_result = self .store .maintenance .send (
190- RemoveConnectionStringOperation ("snowflake1" , ConnectionStringType .SNOWFLAKE )
191- )
186+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (snowflake_connection_string ))
192187 self .assertGreater (remove_result .raft_command_index , 0 )
193188
194189 # 4. Get and Assert None
@@ -208,7 +203,7 @@ def test_full_lifecycle_for_all_connection_string_types(self):
208203 self .assertEqual (1 , len (ai_get_result .ai_connection_strings ))
209204
210205 # 3. Delete
211- remove_result = self .store .maintenance .send (RemoveConnectionStringOperation ("ai1" , ConnectionStringType . AI ))
206+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_connection_string ))
212207 self .assertGreater (remove_result .raft_command_index , 0 )
213208
214209 # 4. Get and Assert None
@@ -237,9 +232,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
237232 self .assertEqual (raven_connection_string .topology_discovery_urls , retrieved .topology_discovery_urls )
238233
239234 # Delete
240- remove_result = self .store .maintenance .send (
241- RemoveConnectionStringOperation ("raven_all_fields" , ConnectionStringType .RAVEN )
242- )
235+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (raven_connection_string ))
243236 self .assertGreater (remove_result .raft_command_index , 0 )
244237
245238 # Get and Assert None
@@ -271,9 +264,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
271264 self .assertEqual (sql_connection_string .factory_name , retrieved .factory_name )
272265
273266 # Delete
274- remove_result = self .store .maintenance .send (
275- RemoveConnectionStringOperation ("sql_all_fields" , ConnectionStringType .SQL )
276- )
267+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (sql_connection_string ))
277268 self .assertGreater (remove_result .raft_command_index , 0 )
278269
279270 # Get and Assert None
@@ -467,9 +458,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
467458 )
468459
469460 # Delete
470- remove_result = self .store .maintenance .send (
471- RemoveConnectionStringOperation ("olap_all_fields" , ConnectionStringType .OLAP )
472- )
461+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (olap_connection_string ))
473462 self .assertGreater (remove_result .raft_command_index , 0 )
474463
475464 # Get and Assert None
@@ -518,9 +507,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
518507 self .assertEqual (openai_chat_settings .dimensions , retrieved .openai_settings .dimensions )
519508
520509 # Delete
521- remove_result = self .store .maintenance .send (
522- RemoveConnectionStringOperation ("ai_openai_chat" , ConnectionStringType .AI )
523- )
510+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_openai_chat_connection_string ))
524511 self .assertGreater (remove_result .raft_command_index , 0 )
525512
526513 # Get and Assert None
@@ -570,7 +557,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
570557
571558 # Delete
572559 remove_result = self .store .maintenance .send (
573- RemoveConnectionStringOperation ("ai_openai_embeddings" , ConnectionStringType . AI )
560+ RemoveConnectionStringOperation (ai_openai_embeddings_connection_string )
574561 )
575562 self .assertGreater (remove_result .raft_command_index , 0 )
576563
@@ -618,9 +605,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
618605 self .assertEqual (azure_openai_settings .dimensions , retrieved .azure_openai_settings .dimensions )
619606
620607 # Delete
621- remove_result = self .store .maintenance .send (
622- RemoveConnectionStringOperation ("ai_azure_openai" , ConnectionStringType .AI )
623- )
608+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_azure_openai_connection_string ))
624609 self .assertGreater (remove_result .raft_command_index , 0 )
625610
626611 # Get and Assert None
@@ -661,9 +646,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
661646 self .assertEqual (ollama_settings .think , retrieved .ollama_settings .think )
662647
663648 # Delete
664- remove_result = self .store .maintenance .send (
665- RemoveConnectionStringOperation ("ai_ollama" , ConnectionStringType .AI )
666- )
649+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_ollama_connection_string ))
667650 self .assertGreater (remove_result .raft_command_index , 0 )
668651
669652 # Get and Assert None
@@ -694,9 +677,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
694677 self .assertIsNotNone (retrieved .embedded_settings )
695678
696679 # Delete
697- remove_result = self .store .maintenance .send (
698- RemoveConnectionStringOperation ("ai_embedded" , ConnectionStringType .AI )
699- )
680+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_embedded_connection_string ))
700681 self .assertGreater (remove_result .raft_command_index , 0 )
701682
702683 # Get and Assert None
@@ -732,9 +713,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
732713 self .assertEqual (google_settings .dimensions , retrieved .google_settings .dimensions )
733714
734715 # Delete
735- remove_result = self .store .maintenance .send (
736- RemoveConnectionStringOperation ("ai_google" , ConnectionStringType .AI )
737- )
716+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_google_connection_string ))
738717 self .assertGreater (remove_result .raft_command_index , 0 )
739718
740719 # Get and Assert None
@@ -774,9 +753,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
774753 self .assertEqual (huggingface_settings .endpoint , retrieved .huggingface_settings .endpoint )
775754
776755 # Delete
777- remove_result = self .store .maintenance .send (
778- RemoveConnectionStringOperation ("ai_huggingface" , ConnectionStringType .AI )
779- )
756+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_huggingface_connection_string ))
780757 self .assertGreater (remove_result .raft_command_index , 0 )
781758
782759 # Get and Assert None
@@ -814,9 +791,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
814791 self .assertEqual (mistral_ai_settings .endpoint , retrieved .mistral_ai_settings .endpoint )
815792
816793 # Delete
817- remove_result = self .store .maintenance .send (
818- RemoveConnectionStringOperation ("ai_mistral" , ConnectionStringType .AI )
819- )
794+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (ai_mistral_connection_string ))
820795 self .assertGreater (remove_result .raft_command_index , 0 )
821796
822797 # Get and Assert None
@@ -881,9 +856,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
881856 )
882857
883858 # Delete
884- remove_result = self .store .maintenance .send (
885- RemoveConnectionStringOperation ("elastic_all_fields" , ConnectionStringType .ELASTIC_SEARCH )
886- )
859+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (elastic_search_connection_string ))
887860 self .assertGreater (remove_result .raft_command_index , 0 )
888861
889862 # Get and Assert None
@@ -1016,9 +989,7 @@ def test_all_possible_fields_for_each_connection_string_type(self):
1016989 )
1017990
1018991 # Delete
1019- remove_result = self .store .maintenance .send (
1020- RemoveConnectionStringOperation ("queue_all_fields" , ConnectionStringType .QUEUE )
1021- )
992+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (queue_connection_string ))
1022993 self .assertGreater (remove_result .raft_command_index , 0 )
1023994
1024995 # Get and Assert None
@@ -1048,13 +1019,31 @@ def test_all_possible_fields_for_each_connection_string_type(self):
10481019 self .assertEqual (snowflake_connection_string .connection_string , retrieved .connection_string )
10491020
10501021 # Delete
1051- remove_result = self .store .maintenance .send (
1052- RemoveConnectionStringOperation ("snowflake_all_fields" , ConnectionStringType .SNOWFLAKE )
1053- )
1022+ remove_result = self .store .maintenance .send (RemoveConnectionStringOperation (snowflake_connection_string ))
10541023 self .assertGreater (remove_result .raft_command_index , 0 )
10551024
10561025 # Get and Assert None
10571026 after_delete = self .store .maintenance .send (
10581027 GetConnectionStringsOperation ("snowflake_all_fields" , ConnectionStringType .SNOWFLAKE )
10591028 )
10601029 self .assertIsNone (after_delete .snowflake_connection_strings )
1030+
1031+ def test_remove_connection_string_by_name_operation (self ):
1032+ raven_connection_string = RavenConnectionString ("raven1" , self .store .database , self .store .urls )
1033+
1034+ put_result = self .store .maintenance .send (PutConnectionStringOperation (raven_connection_string ))
1035+ self .assertGreater (put_result .raft_command_index , 0 )
1036+
1037+ raven_get_result = self .store .maintenance .send (
1038+ GetConnectionStringsOperation ("raven1" , ConnectionStringType .RAVEN )
1039+ )
1040+ self .assertIn ("raven1" , raven_get_result .raven_connection_strings )
1041+ self .assertEqual (1 , len (raven_get_result .raven_connection_strings ))
1042+
1043+ remove_result = self .store .maintenance .send (
1044+ RemoveConnectionStringByNameOperation ("raven1" , ConnectionStringType .RAVEN )
1045+ )
1046+ self .assertGreater (remove_result .raft_command_index , 0 )
1047+
1048+ after_delete = self .store .maintenance .send (GetConnectionStringsOperation ("raven1" , ConnectionStringType .RAVEN ))
1049+ self .assertIsNone (after_delete .raven_connection_strings )
0 commit comments