@@ -269,3 +269,41 @@ def test_server_downloadLogs(tmpdir, plex):
269269def test_server_downloadDatabases (tmpdir , plex ):
270270 plex .downloadDatabases (savepath = str (tmpdir ), unpack = True )
271271 assert len (tmpdir .listdir ()) > 1
272+
273+ def test_server_allowMediaDeletion (account ):
274+ plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
275+ # Check server current allowMediaDeletion setting
276+ if plex .allowMediaDeletion :
277+ # If allowed then test disallowed
278+ plex ._allowMediaDeletion (False )
279+ time .sleep (1 )
280+ plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
281+ assert plex .allowMediaDeletion is None
282+ # Test redundant toggle
283+ with pytest .raises (BadRequest ):
284+ plex ._allowMediaDeletion (False )
285+
286+ plex ._allowMediaDeletion (True )
287+ time .sleep (1 )
288+ plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
289+ assert plex .allowMediaDeletion is True
290+ # Test redundant toggle
291+ with pytest .raises (BadRequest ):
292+ plex ._allowMediaDeletion (True )
293+ else :
294+ # If disallowed then test allowed
295+ plex ._allowMediaDeletion (True )
296+ time .sleep (1 )
297+ plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
298+ assert plex .allowMediaDeletion is True
299+ # Test redundant toggle
300+ with pytest .raises (BadRequest ):
301+ plex ._allowMediaDeletion (True )
302+
303+ plex ._allowMediaDeletion (False )
304+ time .sleep (1 )
305+ plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
306+ assert plex .allowMediaDeletion is None
307+ # Test redundant toggle
308+ with pytest .raises (BadRequest ):
309+ plex ._allowMediaDeletion (False )
0 commit comments