changeset 904:95dabdb0c799

test: update radiocol test regarding the last changes
author souliane <souliane@mailoo.org>
date Sat, 15 Mar 2014 01:19:22 +0100
parents c3fdf187a73a
children cad8e52bb2e6
files src/test/test_plugin_misc_radiocol.py
diffstat 1 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/test/test_plugin_misc_radiocol.py	Tue Mar 11 11:59:11 2014 +0100
+++ b/src/test/test_plugin_misc_radiocol.py	Sat Mar 15 01:19:22 2014 +0100
@@ -73,7 +73,7 @@
         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 @@
         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 @@
             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 @@
     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 @@
         """
         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 @@
 
         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 @@
         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