tests: improve audio tests (#1294)

This commit is contained in:
ReenigneArcher 2023-11-13 13:35:36 -05:00 committed by GitHub
parent 4924320715
commit 799e5c690b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -9,6 +9,10 @@ from . import test_media, test_mixins
def test_audio_Artist_attr(artist): def test_audio_Artist_attr(artist):
artist_guids = [
"mbid://069a1c1f-14eb-4d36-b0a0-77dffbd67713",
"plex://artist/5d07bdaf403c64029060f8c4",
]
artist.reload() artist.reload()
assert utils.is_datetime(artist.addedAt) assert utils.is_datetime(artist.addedAt)
assert artist.albumSort == -1 assert artist.albumSort == -1
@ -17,8 +21,8 @@ def test_audio_Artist_attr(artist):
if artist.countries: if artist.countries:
assert "United States of America" in [i.tag for i in artist.countries] assert "United States of America" in [i.tag for i in artist.countries]
# assert "Electronic" in [i.tag for i in artist.genres] # assert "Electronic" in [i.tag for i in artist.genres]
assert artist.guid == "plex://artist/5d07bdaf403c64029060f8c4" assert artist.guid in artist_guids
assert "mbid://069a1c1f-14eb-4d36-b0a0-77dffbd67713" in [i.id for i in artist.guids] assert artist_guids[0] in [i.id for i in artist.guids]
assert artist.index == 1 assert artist.index == 1
assert utils.is_metadata(artist._initpath) assert utils.is_metadata(artist._initpath)
assert utils.is_metadata(artist.key) assert utils.is_metadata(artist.key)

View file

@ -785,15 +785,15 @@ def _test_library_search(library, obj): # noqa: C901
fields = library.listFields(obj.type) fields = library.listFields(obj.type)
for field in fields: for field in fields:
fieldAttr = field.key.split(".")[-1] fieldAttr = field.key.split(".")[-1]
if fieldAttr in {"unmatched", "userRating"}:
continue
operators = library.listOperators(field.type) operators = library.listOperators(field.type)
if field.type in {"tag", "string"}: if field.type in {"tag", "string"}:
operators += [andOp] operators += [andOp]
for operator in operators: for operator in operators:
if ( if (
fieldAttr == "unmatched" and operator.key == "!=" fieldAttr in {"audienceRating", "rating"} and operator.key in {"=", "!="}
or fieldAttr in {"audienceRating", "rating"} and operator.key in {"=", "!="}
or fieldAttr == "userRating"
): ):
continue continue
@ -846,7 +846,7 @@ def _do_test_library_search(library, obj, field, operator, searchValue):
if operator.key.startswith("!") or operator.key.startswith(">>") and (searchValue == 1 or searchValue == "1s"): if operator.key.startswith("!") or operator.key.startswith(">>") and (searchValue == 1 or searchValue == "1s"):
assert obj not in results assert obj not in results
else: else:
assert obj in results assert obj in results, f"Unable to search {obj.type} by {field.key} using {operator.key} and value {searchValue}."
def test_library_common(movies): def test_library_common(movies):