Mercurial > libervia-backend
diff src/test/test_plugin_misc_radiocol.py @ 1271:2308f8405ffb
test: refactoring:
- rename internal init methods to reinit
- rename getSentMessage to getSentMessageXml
- rename getSentMessageRaw to getSentMessage
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 19 Dec 2014 11:36:00 +0100 |
parents | b3f383ab39da |
children | 979210da778a |
line wrap: on
line diff
--- a/src/test/test_plugin_misc_radiocol.py Mon Dec 15 15:29:08 2014 +0100 +++ b/src/test/test_plugin_misc_radiocol.py Fri Dec 19 11:36:00 2014 +0100 @@ -55,8 +55,8 @@ def setUp(self): self.host = helpers.FakeSAT() - def init(self): - self.host.init() + def reinit(self): + self.host.reinit() self.host.plugins['ROOM-GAME'] = plugin_room_game.RoomGame(self.host) self.plugin = plugin.Radiocol(self.host) # must be init after ROOM-GAME self.plugin.testing = True @@ -109,7 +109,7 @@ """Check if the message "song_rejected" has been sent by the referee and process the command with the profile of the uploader @param profile_index: uploader's profile""" - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) content = "<song_rejected xmlns='' reason='Too many songs in queue'/>" self.assertEqualXML(sent.toXml(), self._expectedMessage(ROOM_JID_S + '/' + self.plugin_0045.getNick(0, profile_index), 'normal', content)) self._roomGameCmd(sent, ['radiocolSongRejected', ROOM_JID_S, 'Too many songs in queue']) @@ -117,7 +117,7 @@ def _noUploadCb(self): """Check if the message "no_upload" has been sent by the referee and process the command with the profiles of each room users""" - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) content = "<no_upload xmlns=''/>" self.assertEqualXML(sent.toXml(), self._expectedMessage(ROOM_JID_S, 'groupchat', content)) self._roomGameCmd(sent, ['radiocolNoUpload', ROOM_JID_S]) @@ -125,7 +125,7 @@ def _uploadOkCb(self): """Check if the message "upload_ok" has been sent by the referee and process the command with the profiles of each room users""" - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) content = "<upload_ok xmlns=''/>" self.assertEqualXML(sent.toXml(), self._expectedMessage(ROOM_JID_S, 'groupchat', content)) self._roomGameCmd(sent, ['radiocolUploadOk', ROOM_JID_S]) @@ -136,7 +136,7 @@ @param attrs: information dict about the song @param profile_index: profile index of the uploader """ - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) attrs['sender'] = self.plugin_0045.getNick(0, profile_index) radiocol_elt = domish.generateElementsNamed(sent.elements(), 'radiocol').next() preload_elt = domish.generateElementsNamed(radiocol_elt.elements(), 'preload').next() @@ -150,7 +150,7 @@ def _playNextSongCb(self): """Check if the message "play" has been sent by the referee and process the command with the profiles of each room users""" - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) filename = self.playlist.pop(0) content = "<play xmlns='' filename='%s' />" % filename self.assertEqualXML(sent.toXml(), self._expectedMessage(ROOM_JID_S, 'groupchat', content)) @@ -181,7 +181,7 @@ self.assertEqual(game_data['to_delete'][attrs['filename']], filepath) content = "<song_added xmlns='' %s/>" % " ".join(["%s='%s'" % (attr, attrs[attr]) for attr in attrs]) - sent = self.host.getSentMessageRaw(profile_index) + sent = self.host.getSentMessage(profile_index) self.assertEqualXML(sent.toXml(), self._expectedMessage(REFEREE_FULL, 'normal', content)) reject_song = len(game_data['queue']) >= plugin.QUEUE_LIMIT @@ -240,7 +240,7 @@ """ for nick in sync_data: expected = self._expectedMessage(ROOM_JID_S + '/' + nick, 'normal', sync_data[nick]) - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) self.assertEqualXML(sent.toXml(), expected) for elt in sync_data[nick]: if elt.name == 'preload': @@ -273,7 +273,7 @@ # Check that the message "players" has been sent by the referee expected = self._expectedMessage(to_jid, type_, self._buildPlayers(nicks)) - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) self.assertEqualXML(sent.toXml(), expected) # Process the command with the profiles of each room users @@ -332,14 +332,14 @@ d.addCallbacks(eb, eb) def test_init(self): - self.init() + self.reinit() self.assertEqual(self.plugin.invite_mode, self.plugin.FROM_PLAYERS) self.assertEqual(self.plugin.wait_mode, self.plugin.FOR_NONE) self.assertEqual(self.plugin.join_mode, self.plugin.INVITED) self.assertEqual(self.plugin.ready_mode, self.plugin.FORCE) def test_game(self): - self.init() + self.reinit() # create game self.plugin.prepareRoom(OTHER_PLAYERS, ROOM_JID_S, PROFILE) @@ -347,7 +347,7 @@ room = self.plugin_0045.getRoom(0, 0) nicks = [self.plugin_0045.getNick(0, 0)] - sent = self.host.getSentMessageRaw(0) + sent = self.host.getSentMessage(0) self.assertEqualXML(sent.toXml(), self._expectedMessage(ROOM_JID_S, 'groupchat', self._buildPlayers(nicks))) self._roomGameCmd(sent, ['radiocolStarted', ROOM_JID_S, REFEREE_FULL, nicks, [plugin.QUEUE_TO_START, plugin.QUEUE_LIMIT]])