@@ -272,12 +272,38 @@ def test_server_downloadDatabases(tmpdir, plex):
272272
273273def test_server_allowMediaDeletion (account ):
274274 plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
275- plex ._allowMediaDeletion (True )
276- time .sleep (1 )
277- plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
278- assert plex .allowMediaDeletion == True
279- plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
280- plex ._allowMediaDeletion (False )
281- time .sleep (1 )
282- plex = PlexServer (utils .SERVER_BASEURL , account .authenticationToken )
283- assert plex .allowMediaDeletion == None
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