From 4473ff08d340d4f252f29270ba50af029a459ee3 Mon Sep 17 00:00:00 2001 From: Hellow <74311245+HeIIow2@users.noreply.github.com> Date: Sat, 13 Apr 2024 15:36:16 +0200 Subject: [PATCH] feat: tested album artist relation --- tests/collection.py | 56 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/tests/collection.py b/tests/collection.py index e857fff..9e95e16 100644 --- a/tests/collection.py +++ b/tests/collection.py @@ -1,18 +1,13 @@ import unittest -import music_kraken -from music_kraken.objects import Song, Album, Artist, Collection +from music_kraken.objects import Song, Album, Artist, Collection, Country class TestCollection(unittest.TestCase): - def test_song_album_relation(self): - """ - Tests that - album = album.any_song.one_album - is the same object - """ - - artist: Artist = Artist( + @staticmethod + def complicated_object() -> Artist: + return Artist( name="artist", + country=Country.by_alpha_2("DE"), main_album_list=[ Album( title="album", @@ -35,7 +30,14 @@ class TestCollection(unittest.TestCase): ] ) - a = artist.main_album_collection[0] + def test_song_album_relation(self): + """ + Tests that + album = album.any_song.one_album + is the same object + """ + + a = self.complicated_object().main_album_collection[0] b = a.song_collection[0].album_collection[0] c = a.song_collection[1].album_collection[0] d = b.song_collection[0].album_collection[0] @@ -52,5 +54,37 @@ class TestCollection(unittest.TestCase): self.assertTrue(a.title == b.title == c.title == d.title == e.title == f.title == g.title == "new_title") + def test_album_artist_relation(self): + """ + Tests that + artist = artist.any_album.any_song.one_artist + is the same object + """ + + a = self.complicated_object() + b = a.main_album_collection[0].artist_collection[0] + c = b.main_album_collection[0].artist_collection[0] + d = c.main_album_collection[0].artist_collection[0] + + self.assertTrue(a.id == b.id == c.id == d.id) + self.assertTrue(a.name == b.name == c.name == d.name == "artist") + self.assertTrue(a.country == b.country == c.country == d.country) + + def test_song_artist_relations(self): + """ + Tests that + artist = artist.any_album.any_song.one_artist + is the same object + """ + + a = self.complicated_object() + b = a.main_album_collection[0].song_collection[0].main_artist_collection[0] + c = b.main_album_collection[0].song_collection[0].main_artist_collection[0] + d = c.main_album_collection[0].song_collection[0].main_artist_collection[0] + + self.assertTrue(a.id == b.id == c.id == d.id) + self.assertTrue(a.name == b.name == c.name == d.name == "artist") + self.assertTrue(a.country == b.country == c.country == d.country) + if __name__ == "__main__": unittest.main()