From 9366eb46fd10ec67c6ae14655a9b9dafcd24045f Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 12 Apr 2024 17:58:18 +0200 Subject: [PATCH] feat: added first test --- tests/__init__.py | 0 tests/collection.py | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/collection.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/collection.py b/tests/collection.py new file mode 100644 index 0000000..e857fff --- /dev/null +++ b/tests/collection.py @@ -0,0 +1,56 @@ +import unittest + +import music_kraken +from music_kraken.objects import Song, Album, Artist, Collection + +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( + name="artist", + main_album_list=[ + Album( + title="album", + song_list=[ + Song( + title="song", + album_list=[ + Album(title="album", albumsort=123), + ], + ), + Song( + title="other_song", + album_list=[ + Album(title="album", albumsort=423), + ], + ), + ] + ), + Album(title="album", barcode="1234567890123"), + ] + ) + + a = artist.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] + e = d.song_collection[0].album_collection[0] + f = e.song_collection[0].album_collection[0] + g = f.song_collection[0].album_collection[0] + + self.assertTrue(a.id == b.id == c.id == d.id == e.id == f.id == g.id) + self.assertTrue(a.title == b.title == c.title == d.title == e.title == f.title == g.title == "album") + self.assertTrue(a.barcode == b.barcode == c.barcode == d.barcode == e.barcode == f.barcode == g.barcode == "1234567890123") + self.assertTrue(a.albumsort == b.albumsort == c.albumsort == d.albumsort == e.albumsort == f.albumsort == g.albumsort == 123) + + d.title = "new_title" + + self.assertTrue(a.title == b.title == c.title == d.title == e.title == f.title == g.title == "new_title") + +if __name__ == "__main__": + unittest.main()