def test_insert_new_artist(self): artist1 = ArtistNode(parent=self.root) artist1.metadata = {u'artist': u'test_artist1'} self.db.upsert(None, { u'artist': u'test_artist2' }) artist2 = self.root.child(1) assert artist2.metadata == {u'artist': u'test_artist2'}
def test_insert_new_album_to_artist(self): artist = ArtistNode(parent=self.root) artist.metadata = {u'artist': u'test_artist'} result = { u'artist': u'test_artist', u'year': u'2012', u'album': u'test_album' } self.db.upsert(None, result) album = artist.child(0) assert album.metadata == result assert artist.metadata == result
def test_insert_new_track_to_album(self): artist = ArtistNode(parent=self.root) artist.metadata = {u'artist': u'test_artist'} album = AlbumNode(parent=artist) album.metadata = {u'year': u'2012', u'album': u'test_album'} result = { u'artist': u'test_artist', u'year': u'2012', u'album': u'test_album', u'tracknumber': u'12', u'title': u'test_title' } self.db.upsert(None, result) track = album.child(0) assert track.metadata == result assert album.metadata == result assert artist.metadata == result
class BaseTest(object): def setUp(self): self.path = os.path.join(__file__, u"..", u"..", u"data", u"empty") self.path = os.path.normpath(self.path) os.mkdir(self.path) self.meta = { u"artist": u"test_artist1", u"year": u"2012", u"album": u"test_album1", u"tracknumber": u"12", u"title": u"test_title1", } self.root = _Node(self.path) self.artist = ArtistNode(parent=self.root) self.artist.update(self.meta.copy()) self.artist._path = os.path.join(self.path, self.artist.fn_encode(self.meta[u"artist"])) def tearDown(self): shutil.rmtree(self.path)