1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Added tests for flac and ogg

This commit is contained in:
Taizo Simpson 2018-10-08 21:19:22 -04:00
parent 4bbcbd0acf
commit a2add86550
No known key found for this signature in database
GPG Key ID: D197B1197B2D4D68
5 changed files with 28 additions and 24 deletions

View File

@ -50,21 +50,24 @@ class MediaTestCase(ApiTestBase):
last_modification = 0 last_modification = 0
) )
self.trackid = track.id self.trackid = track.id
track_embeded_art = Track(
title = '[silence]', self.formats = [('mp3','mpeg'), ('flac','flac'), ('ogg','ogg')]
number = 1, for i in range(len(self.formats)):
disc = 1, track_embeded_art = Track(
artist = artist, title = '[silence]',
album = album, number = 1,
path = os.path.abspath('tests/assets/folder/silence.mp3'), disc = 1,
root_folder = folder, artist = artist,
folder = folder, album = album,
duration = 2, path = os.path.abspath('tests/assets/formats/silence.{0}'.format(self.formats[i][0])),
bitrate = 320, root_folder = folder,
content_type = 'audio/mpeg', folder = folder,
last_modification = 0 duration = 2,
) bitrate = 320,
self.trackid_embeded_art = track_embeded_art.id content_type = 'audio/{0}'.format(self.formats[i][1]),
last_modification = 0
)
self.formats[i] = track_embeded_art.id
def test_stream(self): def test_stream(self):
self._make_request('stream', error = 10) self._make_request('stream', error = 10)
@ -137,13 +140,13 @@ class MediaTestCase(ApiTestBase):
# TODO test non square covers # TODO test non square covers
# Test extracting cover art from embeded media # Test extracting cover art from embeded media
args['id'] = str(self.trackid_embeded_art) for args['id'] in self.formats:
rv = self.client.get('/rest/getCoverArt.view', query_string = args) rv = self.client.get('/rest/getCoverArt.view', query_string = args)
self.assertEqual(rv.status_code, 200) self.assertEqual(rv.status_code, 200)
self.assertEqual(rv.mimetype, 'image/png') self.assertEqual(rv.mimetype, 'image/png')
im = Image.open(BytesIO(rv.data)) im = Image.open(BytesIO(rv.data))
self.assertEqual(im.format, 'PNG') self.assertEqual(im.format, 'PNG')
self.assertEqual(im.size, (120, 120)) self.assertEqual(im.size, (120, 120))
def test_get_lyrics(self): def test_get_lyrics(self):
self._make_request('getLyrics', error = 10) self._make_request('getLyrics', error = 10)

Binary file not shown.

View File

@ -0,0 +1 @@
../folder/silence.mp3

Binary file not shown.

View File

@ -26,7 +26,7 @@ class ScannerTestCase(unittest.TestCase):
db.init_database('sqlite:') db.init_database('sqlite:')
with db_session: with db_session:
folder = FolderManager.add('folder', os.path.abspath('tests/assets')) folder = FolderManager.add('folder', os.path.abspath('tests/assets/folder'))
self.assertIsNotNone(folder) self.assertIsNotNone(folder)
self.folderid = folder.id self.folderid = folder.id
@ -126,7 +126,7 @@ class ScannerTestCase(unittest.TestCase):
self.assertEqual(db.Track.select().count(), 1) self.assertEqual(db.Track.select().count(), 1)
track = db.Track.select().first() track = db.Track.select().first()
new_path = os.path.abspath(os.path.join(os.path.dirname(track.path), '..', 'silence.mp3')) new_path = track.path.replace('silence','silence_moved')
self.scanner.move_file(track.path, new_path) self.scanner.move_file(track.path, new_path)
commit() commit()
self.assertEqual(db.Track.select().count(), 1) self.assertEqual(db.Track.select().count(), 1)