test: update radiocol test regarding the last changes
This commit is contained in:
parent
e8f9ca2c0f
commit
3249e50efe
1 changed files with 9 additions and 11 deletions
|
|
@ -73,7 +73,7 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
self.sound_dir = self.host.memory.getConfig('', 'media_dir') + '/test/sound/'
|
||||
try:
|
||||
for filename in os.listdir(self.sound_dir):
|
||||
if filename.endswith('.ogg'):
|
||||
if filename.endswith('.ogg') or filename.endswith('.mp3'):
|
||||
self.songs.append(filename)
|
||||
except OSError:
|
||||
raise SkipTest('The sound samples in sat_media/test/sound were not found')
|
||||
|
|
@ -145,7 +145,7 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
if sent.hasAttribute('from'):
|
||||
del sent['from']
|
||||
self.assertEqualXML(sent.toXml(), self._expectedMessage(ROOM_JID_S, 'groupchat', content))
|
||||
self._roomGameCmd(sent, ['radiocolPreload', ROOM_JID_S, attrs['timestamp'], attrs['filename'], attrs['title'], attrs['artist'], attrs['album']])
|
||||
self._roomGameCmd(sent, ['radiocolPreload', ROOM_JID_S, attrs['timestamp'], attrs['filename'], attrs['title'], attrs['artist'], attrs['album'], attrs['sender']])
|
||||
|
||||
def _playNextSongCb(self):
|
||||
"""Check if the message "play" has been sent by the referee
|
||||
|
|
@ -244,7 +244,7 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
self.assertEqualXML(sent.toXml(), expected)
|
||||
for elt in sync_data[nick]:
|
||||
if elt.name == 'preload':
|
||||
self.host.bridge.expectCall('radiocolPreload', ROOM_JID_S, elt['timestamp'], elt['filename'], elt['title'], elt['artist'], elt['album'], Const.PROFILE[profile_index])
|
||||
self.host.bridge.expectCall('radiocolPreload', ROOM_JID_S, elt['timestamp'], elt['filename'], elt['title'], elt['artist'], elt['album'], elt['sender'], Const.PROFILE[profile_index])
|
||||
elif elt.name == 'play':
|
||||
self.host.bridge.expectCall('radiocolPlay', ROOM_JID_S, elt['filename'], Const.PROFILE[profile_index])
|
||||
elif elt.name == 'no_upload':
|
||||
|
|
@ -297,8 +297,7 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
def _uploadSong(self, song_index, profile_index, ext='ogg'):
|
||||
"""Upload the song of index song_index (modulo self.songs size)
|
||||
from the profile of index profile_index. All the songs in self.songs
|
||||
are OGG, but you can set ext to a value different than 'ogg':
|
||||
- 'mp3' to test unsupported file format (MP3 file should exist)
|
||||
are OGG, but you can set ext to a value different than 'ogg' or 'mp3':
|
||||
- 'xxx' to test non existent files
|
||||
@param song_index: index of the song
|
||||
@param profile_index: index of the uploader's profile
|
||||
|
|
@ -306,8 +305,8 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
"""
|
||||
song_index = song_index % len(self.songs)
|
||||
src_filename = self.songs[song_index]
|
||||
if ext != 'ogg':
|
||||
src_filename.replace('ogg', ext)
|
||||
if ext not in ('ogg', 'mp3'):
|
||||
src_filename = os.path.splitext(src_filename)[0] + '.' + ext
|
||||
dst_filepath = '/tmp/%s.%s' % (uuid.uuid1(), ext)
|
||||
expect_io_error = ext == 'xxx'
|
||||
if not expect_io_error:
|
||||
|
|
@ -324,10 +323,10 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
|
||||
def eb(failure):
|
||||
if not isinstance(failure, Failure):
|
||||
self.fail("Adding a song which is not OGG should fail!")
|
||||
self.fail("Adding a song which is not OGG nor MP3 should fail!")
|
||||
self.assertEqual(failure.value.__class__, exceptions.DataError)
|
||||
|
||||
if self.songs[song_index].endswith('.ogg'):
|
||||
if self.songs[song_index].endswith('.ogg') or self.songs[song_index].endswith('.mp3'):
|
||||
d.addCallbacks(cb, cb)
|
||||
else:
|
||||
d.addCallbacks(eb, eb)
|
||||
|
|
@ -356,8 +355,7 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
self._joinRoom(room, nicks, 4) # user not playing joins
|
||||
|
||||
song_index = 0
|
||||
self._uploadSong(song_index, 0) # ogg file should exist in sat_media/test/song
|
||||
self._uploadSong(song_index, 0, 'mp3') # mp3 file should exist in sat_media/test/song
|
||||
self._uploadSong(song_index, 0) # ogg or mp3 file should exist in sat_media/test/song
|
||||
self._uploadSong(song_index, 0, 'xxx') # file should not exist
|
||||
|
||||
# another songs are added by Const.JID[1] until the radio starts + 1 to fill the queue
|
||||
|
|
|
|||
Loading…
Reference in a new issue