From 5494c1e90d1f8bd78dd56961b25d0572f0618570 Mon Sep 17 00:00:00 2001 From: blacktwin Date: Mon, 20 Dec 2021 00:12:51 -0500 Subject: [PATCH] Change test to use Other Videos library type to prevent scanning Tests: Create library with multiple paths with valid paths Create library with multiple paths with an invalid path Create library with no path Add path(s) to test library with an invalid path Remove path(s) to test library with an invalid path Remove path(s) to test library with valid paths Add path(s) to test library with valid paths --- tests/test_library.py | 47 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/tests/test_library.py b/tests/test_library.py index bc79e9ae..a002b892 100644 --- a/tests/test_library.py +++ b/tests/test_library.py @@ -121,24 +121,57 @@ def test_library_recentlyAdded(plex): assert len(list(plex.library.recentlyAdded())) -def test_library_add_edit_delete(plex): - # Dont add a location to prevent scanning scanning +def test_library_add_edit_delete(plex, movies, photos): + # Create Other Videos library = No external metadata scanning section_name = "plexapi_test_section" + movie_location = movies.locations[0] + photo_location = photos.locations[0] plex.library.add( name=section_name, type="movie", - agent="com.plexapp.agents.imdb", - scanner="Plex Movie Scanner", + agent="com.plexapp.agents.none", + scanner="Plex Video Files Scanner", language="en", + location=[movie_location, photo_location] ) section = plex.library.section(section_name) assert section.title == section_name + # Create library with an invalid path + error_section_name = "plexapi_error_section" + with pytest.raises(BadRequest): + plex.library.add( + name=error_section_name, + type="movie", + agent="com.plexapp.agents.none", + scanner="Plex Video Files Scanner", + language="en", + location=[movie_location, photo_location[:-1]] + ) + # Create library with no path + with pytest.raises(BadRequest): + plex.library.add( + name=error_section_name, + type="movie", + agent="com.plexapp.agents.none", + scanner="Plex Video Files Scanner", + language="en", + ) + with pytest.raises(BadRequest): + plex.library.section(error_section_name) new_title = "a renamed lib" - section.edit( - name=new_title, type="movie", agent="com.plexapp.agents.imdb" - ) + section.edit(name=new_title) section.reload() assert section.title == new_title + with pytest.raises(BadRequest): + section.addLocations(movie_location[:-1]) + with pytest.raises(BadRequest): + section.removeLocations(movie_location[:-1]) + section.removeLocations(photo_location) + section.reload() + assert len(section.locations) == 1 + section.addLocations(photo_location) + section.reload() + assert len(section.locations) == 2 section.delete() assert section not in plex.library.sections()