@@ -189,6 +189,120 @@ async def testing():
189189 asyncio .run (testing ())
190190
191191
192+ # fmt: off
193+ @pytest .mark .parametrize ("library" , ["THREADS" , "ASYNC" ])
194+ # fmt: on
195+ def test_delete_node_01 (clear_sar , library ): # noqa: F811
196+ """
197+ Tests for the 'add_node' API.
198+ """
199+ if not _is_async (library ):
200+ with SaveRestoreAPI_Threads (base_url = base_url , timeout = 2 ) as SR :
201+ SR .set_auth (username = user_username , password = user_password )
202+
203+ response = SR .add_node (SR .ROOT_NODE_UID , name = "Test Folder" , nodeType = "FOLDER" )
204+ assert response ["name" ] == "Test Folder"
205+ assert response ["nodeType" ] == "FOLDER"
206+ folder_uid = response ["uniqueId" ]
207+
208+ response = SR .add_node (folder_uid , name = "Test Config 1" , nodeType = "CONFIGURATION" )
209+ assert response ["name" ] == "Test Config 1"
210+ assert response ["nodeType" ] == "CONFIGURATION"
211+ node_uid_1 = response ["uniqueId" ]
212+
213+ response = SR .add_node (folder_uid , name = "Test Config 2" , nodeType = "CONFIGURATION" )
214+ assert response ["name" ] == "Test Config 2"
215+ assert response ["nodeType" ] == "CONFIGURATION"
216+ node_uid_2 = response ["uniqueId" ]
217+
218+ SR .delete_node (node_uid_1 )
219+ SR .delete_node (node_uid_2 )
220+ SR .delete_node (folder_uid )
221+
222+ else :
223+ async def testing ():
224+ async with SaveRestoreAPI_Async (base_url = base_url , timeout = 2 ) as SR :
225+ SR .set_auth (username = user_username , password = user_password )
226+
227+ response = await SR .add_node (SR .ROOT_NODE_UID , name = "Test Folder" , nodeType = "FOLDER" )
228+ assert response ["name" ] == "Test Folder"
229+ assert response ["nodeType" ] == "FOLDER"
230+ folder_uid = response ["uniqueId" ]
231+
232+ response = await SR .add_node (folder_uid , name = "Test Config 1" , nodeType = "CONFIGURATION" )
233+ assert response ["name" ] == "Test Config 1"
234+ assert response ["nodeType" ] == "CONFIGURATION"
235+ node_uid_1 = response ["uniqueId" ]
236+
237+ response = await SR .add_node (folder_uid , name = "Test Config 2" , nodeType = "CONFIGURATION" )
238+ assert response ["name" ] == "Test Config 2"
239+ assert response ["nodeType" ] == "CONFIGURATION"
240+ node_uid_2 = response ["uniqueId" ]
241+
242+ await SR .delete_node (node_uid_1 )
243+ await SR .delete_node (node_uid_2 )
244+ await SR .delete_node (folder_uid )
245+
246+ asyncio .run (testing ())
247+
248+
249+ # fmt: off
250+ @pytest .mark .parametrize ("library" , ["THREADS" , "ASYNC" ])
251+ # fmt: on
252+ def test_delete_nodes_01 (clear_sar , library ): # noqa: F811
253+ """
254+ Tests for the 'add_node' API.
255+ """
256+ if not _is_async (library ):
257+ with SaveRestoreAPI_Threads (base_url = base_url , timeout = 2 ) as SR :
258+ SR .set_auth (username = user_username , password = user_password )
259+
260+ response = SR .add_node (SR .ROOT_NODE_UID , name = "Test Folder" , nodeType = "FOLDER" )
261+ assert response ["name" ] == "Test Folder"
262+ assert response ["nodeType" ] == "FOLDER"
263+ folder_uid = response ["uniqueId" ]
264+
265+ response = SR .add_node (folder_uid , name = "Test Config 1" , nodeType = "CONFIGURATION" )
266+ assert response ["name" ] == "Test Config 1"
267+ assert response ["nodeType" ] == "CONFIGURATION"
268+ node_uid_1 = response ["uniqueId" ]
269+
270+ response = SR .add_node (folder_uid , name = "Test Config 2" , nodeType = "CONFIGURATION" )
271+ assert response ["name" ] == "Test Config 2"
272+ assert response ["nodeType" ] == "CONFIGURATION"
273+ node_uid_2 = response ["uniqueId" ]
274+
275+ SR .delete_nodes ([node_uid_1 , node_uid_2 ])
276+ SR .delete_nodes ([folder_uid ])
277+
278+ else :
279+ async def testing ():
280+ async with SaveRestoreAPI_Async (base_url = base_url , timeout = 2 ) as SR :
281+ SR .set_auth (username = user_username , password = user_password )
282+
283+ response = await SR .add_node (SR .ROOT_NODE_UID , name = "Test Folder" , nodeType = "FOLDER" )
284+ assert response ["name" ] == "Test Folder"
285+ assert response ["nodeType" ] == "FOLDER"
286+ folder_uid = response ["uniqueId" ]
287+
288+ response = await SR .add_node (folder_uid , name = "Test Config 1" , nodeType = "CONFIGURATION" )
289+ assert response ["name" ] == "Test Config 1"
290+ assert response ["nodeType" ] == "CONFIGURATION"
291+ node_uid_1 = response ["uniqueId" ]
292+
293+ response = await SR .add_node (folder_uid , name = "Test Config 2" , nodeType = "CONFIGURATION" )
294+ assert response ["name" ] == "Test Config 2"
295+ assert response ["nodeType" ] == "CONFIGURATION"
296+ node_uid_2 = response ["uniqueId" ]
297+
298+ await SR .delete_nodes ([node_uid_1 , node_uid_2 ])
299+ await SR .delete_nodes ([folder_uid ])
300+
301+ asyncio .run (testing ())
302+
303+
304+
305+
192306def test_comm (clear_sar ): # noqa: F811
193307 SR = SaveRestoreAPI_Threads (base_url = base_url , timeout = 2 )
194308 SR .set_auth (username = user_username , password = user_password )
0 commit comments