1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-13 21:52:18 +00:00

Increased managers tests coverage

This commit is contained in:
spl0k 2017-11-20 21:32:35 +01:00
parent 1488f29e9f
commit 79613aed84
2 changed files with 60 additions and 0 deletions

View File

@ -43,6 +43,30 @@ class FolderManagerTestCase(unittest.TestCase):
folder.name = 'non-root' folder.name = 'non-root'
folder.path = os.path.join(self.music_dir, 'subfolder') folder.path = os.path.join(self.music_dir, 'subfolder')
self.store.add(folder) self.store.add(folder)
artist = db.Artist()
artist.name = 'Artist'
album = db.Album()
album.name = 'Album'
album.artist = artist
root = self.store.find(db.Folder, db.Folder.name == 'media').one()
track = db.Track()
track.title = 'Track'
track.artist = artist
track.album = album
track.disc = 1
track.number = 1
track.path = os.path.join(self.media_dir, 'somefile')
track.folder = root
track.root_folder = root
track.duration = 2
track.content_type = 'audio/mpeg'
track.bitrate = 320
track.last_modification = 0
self.store.add(track)
self.store.commit() self.store.commit()
def tearDown(self): def tearDown(self):

View File

@ -33,6 +33,42 @@ class UserManagerTestCase(unittest.TestCase):
self.assertEqual(UserManager.add(self.store, 'bob', 'BOB', 'bob@example.com', False), UserManager.SUCCESS) self.assertEqual(UserManager.add(self.store, 'bob', 'BOB', 'bob@example.com', False), UserManager.SUCCESS)
self.assertEqual(UserManager.add(self.store, 'charlie', 'CHARLIE', 'charlie@example.com', False), UserManager.SUCCESS) self.assertEqual(UserManager.add(self.store, 'charlie', 'CHARLIE', 'charlie@example.com', False), UserManager.SUCCESS)
folder = db.Folder()
folder.name = 'Root'
folder.path = 'tests/assets'
folder.root = True
artist = db.Artist()
artist.name = 'Artist'
album = db.Album()
album.name = 'Album'
album.artist = artist
track = db.Track()
track.title = 'Track'
track.disc = 1
track.number = 1
track.duration = 1
track.artist = artist
track.album = album
track.path = 'tests/assets/empty'
track.folder = folder
track.root_folder = folder
track.duration = 2
track.content_type = 'audio/mpeg'
track.bitrate = 320
track.last_modification = 0
self.store.add(track)
self.store.commit()
playlist = db.Playlist()
playlist.name = 'Playlist'
playlist.user = self.store.find(db.User, db.User.name == 'alice').one()
playlist.add(track)
self.store.add(playlist)
self.store.commit()
def test_encrypt_password(self): def test_encrypt_password(self):
func = UserManager._UserManager__encrypt_password func = UserManager._UserManager__encrypt_password
self.assertEqual(func(u'password',u'salt'), (u'59b3e8d637cf97edbe2384cf59cb7453dfe30789', u'salt')) self.assertEqual(func(u'password',u'salt'), (u'59b3e8d637cf97edbe2384cf59cb7453dfe30789', u'salt'))