mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Added tests for flac and ogg
This commit is contained in:
parent
4bbcbd0acf
commit
a2add86550
@ -50,21 +50,24 @@ class MediaTestCase(ApiTestBase):
|
||||
last_modification = 0
|
||||
)
|
||||
self.trackid = track.id
|
||||
track_embeded_art = Track(
|
||||
title = '[silence]',
|
||||
number = 1,
|
||||
disc = 1,
|
||||
artist = artist,
|
||||
album = album,
|
||||
path = os.path.abspath('tests/assets/folder/silence.mp3'),
|
||||
root_folder = folder,
|
||||
folder = folder,
|
||||
duration = 2,
|
||||
bitrate = 320,
|
||||
content_type = 'audio/mpeg',
|
||||
last_modification = 0
|
||||
)
|
||||
self.trackid_embeded_art = track_embeded_art.id
|
||||
|
||||
self.formats = [('mp3','mpeg'), ('flac','flac'), ('ogg','ogg')]
|
||||
for i in range(len(self.formats)):
|
||||
track_embeded_art = Track(
|
||||
title = '[silence]',
|
||||
number = 1,
|
||||
disc = 1,
|
||||
artist = artist,
|
||||
album = album,
|
||||
path = os.path.abspath('tests/assets/formats/silence.{0}'.format(self.formats[i][0])),
|
||||
root_folder = folder,
|
||||
folder = folder,
|
||||
duration = 2,
|
||||
bitrate = 320,
|
||||
content_type = 'audio/{0}'.format(self.formats[i][1]),
|
||||
last_modification = 0
|
||||
)
|
||||
self.formats[i] = track_embeded_art.id
|
||||
|
||||
def test_stream(self):
|
||||
self._make_request('stream', error = 10)
|
||||
@ -137,13 +140,13 @@ class MediaTestCase(ApiTestBase):
|
||||
# TODO test non square covers
|
||||
|
||||
# Test extracting cover art from embeded media
|
||||
args['id'] = str(self.trackid_embeded_art)
|
||||
rv = self.client.get('/rest/getCoverArt.view', query_string = args)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
self.assertEqual(rv.mimetype, 'image/png')
|
||||
im = Image.open(BytesIO(rv.data))
|
||||
self.assertEqual(im.format, 'PNG')
|
||||
self.assertEqual(im.size, (120, 120))
|
||||
for args['id'] in self.formats:
|
||||
rv = self.client.get('/rest/getCoverArt.view', query_string = args)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
self.assertEqual(rv.mimetype, 'image/png')
|
||||
im = Image.open(BytesIO(rv.data))
|
||||
self.assertEqual(im.format, 'PNG')
|
||||
self.assertEqual(im.size, (120, 120))
|
||||
|
||||
def test_get_lyrics(self):
|
||||
self._make_request('getLyrics', error = 10)
|
||||
|
BIN
tests/assets/formats/silence.flac
Normal file
BIN
tests/assets/formats/silence.flac
Normal file
Binary file not shown.
1
tests/assets/formats/silence.mp3
Symbolic link
1
tests/assets/formats/silence.mp3
Symbolic link
@ -0,0 +1 @@
|
||||
../folder/silence.mp3
|
BIN
tests/assets/formats/silence.ogg
Normal file
BIN
tests/assets/formats/silence.ogg
Normal file
Binary file not shown.
@ -26,7 +26,7 @@ class ScannerTestCase(unittest.TestCase):
|
||||
db.init_database('sqlite:')
|
||||
|
||||
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.folderid = folder.id
|
||||
|
||||
@ -126,7 +126,7 @@ class ScannerTestCase(unittest.TestCase):
|
||||
self.assertEqual(db.Track.select().count(), 1)
|
||||
|
||||
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)
|
||||
commit()
|
||||
self.assertEqual(db.Track.select().count(), 1)
|
||||
|
Loading…
Reference in New Issue
Block a user