Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Nov 8, 2024
1 parent b5f2b68 commit b4ab03b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def _get_fixture_folder(provider: str | None = None) -> pathlib.Path:
tests_base = pathlib.Path(__file__).parent
if provider:
return tests_base / "server" / "providers" / provider / "fixtures"
return tests_base / "providers" / provider / "fixtures"
return tests_base / "fixtures"


Expand Down
25 changes: 13 additions & 12 deletions tests/core/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for mediaitem compare helper functions."""

from music_assistant_models import media_items
from music_assistant_models.enums import ExternalID

from music_assistant.helpers import compare

Expand Down Expand Up @@ -61,19 +62,19 @@ def test_compare_artist() -> None:
artist_b.name = "Artist B"
artist_b.item_id = "2"
artist_b.provider = "test2"
artist_a.external_ids = {(media_items.ExternalID.MB_ARTIST, "123")}
artist_a.external_ids = {(ExternalID.MB_ARTIST, "123")}
artist_b.external_ids = artist_a.external_ids
assert compare.compare_artist(artist_a, artist_b) is True
# test on external id mismatch
artist_b.name = artist_a.name
artist_b.external_ids = {(media_items.ExternalID.MB_ARTIST, "1234")}
artist_b.external_ids = {(ExternalID.MB_ARTIST, "1234")}
assert compare.compare_artist(artist_a, artist_b) is False
# test on external id mismatch while name matches
artist_a = media_items.Artist(
item_id="1",
provider="test1",
name="Artist A",
external_ids={(media_items.ExternalID.MB_ARTIST, "123")},
external_ids={(ExternalID.MB_ARTIST, "123")},
provider_mappings={
media_items.ProviderMapping(
item_id="1", provider_domain="test", provider_instance="test1"
Expand All @@ -84,7 +85,7 @@ def test_compare_artist() -> None:
item_id="1",
provider="test2",
name="Artist A",
external_ids={(media_items.ExternalID.MB_ARTIST, "abc")},
external_ids={(ExternalID.MB_ARTIST, "abc")},
provider_mappings={
media_items.ProviderMapping(
item_id="2", provider_domain="test", provider_instance="test2"
Expand Down Expand Up @@ -168,12 +169,12 @@ def test_compare_album() -> None:
album_b.name = "Album B"
album_b.item_id = "2"
album_b.provider = "test2"
album_a.external_ids = {(media_items.ExternalID.MB_ALBUM, "123")}
album_a.external_ids = {(ExternalID.MB_ALBUM, "123")}
album_b.external_ids = album_a.external_ids
assert compare.compare_album(album_a, album_b) is True
# test on external id mismatch
album_b.name = album_a.name
album_b.external_ids = {(media_items.ExternalID.MB_ALBUM, "1234")}
album_b.external_ids = {(ExternalID.MB_ALBUM, "1234")}
assert compare.compare_album(album_a, album_b) is False
album_a.external_ids = set()
album_b.external_ids = set()
Expand Down Expand Up @@ -297,12 +298,12 @@ def test_compare_track() -> None: # noqa: PLR0915
track_b.name = "Track B"
track_b.item_id = "2"
track_b.provider = "test2"
track_a.external_ids = {(media_items.ExternalID.MB_RECORDING, "123")}
track_a.external_ids = {(ExternalID.MB_RECORDING, "123")}
track_b.external_ids = track_a.external_ids
assert compare.compare_track(track_a, track_b) is True
# test on external id mismatch
track_b.name = track_a.name
track_b.external_ids = {(media_items.ExternalID.MB_RECORDING, "1234")}
track_b.external_ids = {(ExternalID.MB_RECORDING, "1234")}
assert compare.compare_track(track_a, track_b) is False
track_a.external_ids = set()
track_b.external_ids = set()
Expand Down Expand Up @@ -360,11 +361,11 @@ def test_compare_track() -> None: # noqa: PLR0915
# test special case - ISRC match but MusicBrainz ID mismatch
# this can happen for some classical music albums
track_a.external_ids = {
(media_items.ExternalID.ISRC, "123"),
(media_items.ExternalID.MB_RECORDING, "abc"),
(ExternalID.ISRC, "123"),
(ExternalID.MB_RECORDING, "abc"),
}
track_b.external_ids = {
(media_items.ExternalID.ISRC, "123"),
(media_items.ExternalID.MB_RECORDING, "abcd"),
(ExternalID.ISRC, "123"),
(ExternalID.MB_RECORDING, "abcd"),
}
assert compare.compare_track(track_a, track_b) is False
2 changes: 1 addition & 1 deletion tests/core/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from music_assistant.helpers import tags

RESOURCES_DIR = pathlib.Path(__file__).parent.resolve().joinpath("fixtures")
RESOURCES_DIR = pathlib.Path(__file__).parent.parent.resolve().joinpath("fixtures")

FILE_1 = str(RESOURCES_DIR.joinpath("MyArtist - MyTitle.mp3"))

Expand Down
4 changes: 3 additions & 1 deletion tests/providers/jellyfin/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ async def jellyfin_provider(mass: MusicAssistant) -> AsyncGenerator[ProviderConf

authenticate_by_name = f.to_authenticate_by_name()

with mock.patch(".providers.jellyfin.authenticate_by_name", authenticate_by_name):
with mock.patch(
"music_assistant.providers.jellyfin.authenticate_by_name", authenticate_by_name
):
async with wait_for_sync_completion(mass):
config = await mass.config.save_provider_config(
"jellyfin",
Expand Down

0 comments on commit b4ab03b

Please sign in to comment.