test: refactoring:
- rename internal init methods to reinit
- rename getSentMessage to getSentMessageXml
- rename getSentMessageRaw to getSentMessage
This commit is contained in:
parent
a6e6cd68be
commit
852106becd
1 changed files with 115 additions and 95 deletions
|
|
@ -55,8 +55,8 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
"""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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
@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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
"""
|
||||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
|
||||
# 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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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 @@ class RadiocolTest(helpers.SatTestCase):
|
|||
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]])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue