1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-13 21:52: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
self.formats = [('mp3','mpeg'), ('flac','flac'), ('ogg','ogg')]
for i in range(len(self.formats)):
track_embeded_art = Track( track_embeded_art = Track(
title = '[silence]', title = '[silence]',
number = 1, number = 1,
disc = 1, disc = 1,
artist = artist, artist = artist,
album = album, album = album,
path = os.path.abspath('tests/assets/folder/silence.mp3'), path = os.path.abspath('tests/assets/formats/silence.{0}'.format(self.formats[i][0])),
root_folder = folder, root_folder = folder,
folder = folder, folder = folder,
duration = 2, duration = 2,
bitrate = 320, bitrate = 320,
content_type = 'audio/mpeg', content_type = 'audio/{0}'.format(self.formats[i][1]),
last_modification = 0 last_modification = 0
) )
self.trackid_embeded_art = track_embeded_art.id 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,7 +140,7 @@ 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')

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)