mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Update tests for advanced search filters
This commit is contained in:
parent
7b8757419b
commit
4c9aa37cea
1 changed files with 25 additions and 2 deletions
|
@ -206,7 +206,7 @@ def test_library_ShowSection_searchShows(tvshows):
|
|||
assert tvshows.searchShows(title="The 100")
|
||||
|
||||
|
||||
def test_library_ShowSection_searchSseasons(tvshows):
|
||||
def test_library_ShowSection_searchSeasons(tvshows):
|
||||
assert tvshows.searchSeasons(**{"show.title": "The 100"})
|
||||
|
||||
|
||||
|
@ -337,6 +337,23 @@ def test_library_MovieSection_search(movies, movie):
|
|||
movie.removeCollection("test_search", locked=False)
|
||||
|
||||
|
||||
def test_library_MovieSection_advancedSearch(movies, movie):
|
||||
advancedFilters = {
|
||||
'and': [
|
||||
{
|
||||
'or': [
|
||||
{'title': 'elephant'},
|
||||
{'title': 'bunny'}
|
||||
]
|
||||
},
|
||||
{'year>>': 1990},
|
||||
{'unwatched': True}
|
||||
]
|
||||
}
|
||||
results = movies.search(filters=advancedFilters)
|
||||
assert movie in results
|
||||
|
||||
|
||||
def test_library_ShowSection_search(tvshows, show):
|
||||
show.addLabel("test_search")
|
||||
show.addCollection("test_search")
|
||||
|
@ -518,6 +535,12 @@ def test_library_search_exceptions(movies):
|
|||
movies.search(year="123abc")
|
||||
with pytest.raises(BadRequest):
|
||||
movies.search(sort="123abc")
|
||||
with pytest.raises(BadRequest):
|
||||
movies.search(filters=[])
|
||||
with pytest.raises(BadRequest):
|
||||
movies.search(filters={'and': {'title': 'test'}})
|
||||
with pytest.raises(BadRequest):
|
||||
movies.search(filters={'and': [], 'title': 'test'})
|
||||
with pytest.raises(NotFound):
|
||||
movies.getFilterType(libtype="show")
|
||||
with pytest.raises(NotFound):
|
||||
|
@ -594,7 +617,7 @@ def _test_library_search(library, obj):
|
|||
|
||||
def _do_test_library_search(library, obj, field, operator, searchValue):
|
||||
searchFilter = {field.key + operator.key[:-1]: searchValue}
|
||||
results = library.search(libtype=obj.type, **searchFilter)
|
||||
results = library.search(libtype=obj.type, filters=searchFilter)
|
||||
|
||||
if operator.key.startswith("!") or operator.key.startswith(">>") and (searchValue == 1 or searchValue == "1s"):
|
||||
assert obj not in results
|
||||
|
|
Loading…
Reference in a new issue