1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 19:52:16 +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
)
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)

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:')
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)