Skip to content

Commit

Permalink
Add test_play, rename fa.play to fa.run
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheeo committed Nov 25, 2014
1 parent 8bf1987 commit f352aef
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/faftools
Submodule faftools updated 1 files
+1 −1 api/irestservice.py
3 changes: 1 addition & 2 deletions src/client/_clientwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1937,8 +1937,7 @@ def handle_game_launch(self, message):

game_info = dict(uid=message['uid'], recorder=self.login, featured_mod=message[modkey], game_time=time.time(), version_info=version_info)


fa.play(game_info, self.relayServer.serverPort(), arguments)
fa.run(game_info, self.relayServer.serverPort(), arguments)



Expand Down
2 changes: 1 addition & 1 deletion src/fa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

# We only want one instance of Forged Alliance to run, so we use a singleton here (other modules may wish to connect to its signals so it needs persistence)
from process import instance as instance
from play import play
from play import run
from replay import replay

import check
Expand Down
7 changes: 4 additions & 3 deletions src/fa/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#-------------------------------------------------------------------------------
from fa import mods

from process import instance
from .process import instance

import util
import os
Expand Down Expand Up @@ -52,7 +52,7 @@ def build_argument_list(game_info, port, arguments=None):

#live replay
arguments.append('/savereplay')
arguments.append('gpgnet://localhost/' + str(game_info['uid']) + "/" + str(game_info['recorder']) + '.SCFAreplay')
arguments.append('"gpgnet://localhost/' + str(game_info['uid']) + "/" + str(game_info['recorder']) + '.SCFAreplay"')

#disable bug reporter
arguments.append('/nobugreport')
Expand All @@ -63,9 +63,10 @@ def build_argument_list(game_info, port, arguments=None):
return arguments


def play(game_info, port, arguments=None):
def run(game_info, port, arguments=None):
"""
Launches Forged Alliance with the given arguments
"""
logger.info("Play received arguments: %s" % arguments)
arguments = build_argument_list(game_info, port, arguments)
return instance.run(game_info, arguments)
21 changes: 21 additions & 0 deletions tests/fa/test_play.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
__author__ = 'Sheeo'

from flexmock import flexmock

process_mock = flexmock()

import fa
import fa.play

fa.play.instance = process_mock


def test_launches_process_with_given_arguments():
game_info = {
'uid': 0,
'recorder': 'Sheeo'
}
args = ['/some-arg', 'test']
process_mock.should_receive('run').with_args(game_info, args).and_return(True).once()
assert fa.run(game_info, 0, args)

0 comments on commit f352aef

Please sign in to comment.