From f352aef56ee6ebaaaf66d62338dbdf5e1994e62d Mon Sep 17 00:00:00 2001 From: Michael Sondergaard Date: Tue, 25 Nov 2014 22:56:23 +0100 Subject: [PATCH] Add test_play, rename fa.play to fa.run --- lib/faftools | 2 +- src/client/_clientwindow.py | 3 +-- src/fa/__init__.py | 2 +- src/fa/play.py | 7 ++++--- tests/fa/test_play.py | 21 +++++++++++++++++++++ 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 tests/fa/test_play.py diff --git a/lib/faftools b/lib/faftools index 71356e472..a00e165cf 160000 --- a/lib/faftools +++ b/lib/faftools @@ -1 +1 @@ -Subproject commit 71356e47267dba1b3e4180f10a3d261cf998bb05 +Subproject commit a00e165cfa34ceb0b31aa2867994afb815f15557 diff --git a/src/client/_clientwindow.py b/src/client/_clientwindow.py index 16621b49d..0da644f62 100644 --- a/src/client/_clientwindow.py +++ b/src/client/_clientwindow.py @@ -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) diff --git a/src/fa/__init__.py b/src/fa/__init__.py index d17027708..2381bf396 100644 --- a/src/fa/__init__.py +++ b/src/fa/__init__.py @@ -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 diff --git a/src/fa/play.py b/src/fa/play.py index 6860caf92..11b46e154 100644 --- a/src/fa/play.py +++ b/src/fa/play.py @@ -17,7 +17,7 @@ #------------------------------------------------------------------------------- from fa import mods -from process import instance +from .process import instance import util import os @@ -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') @@ -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) diff --git a/tests/fa/test_play.py b/tests/fa/test_play.py new file mode 100644 index 000000000..b4657f410 --- /dev/null +++ b/tests/fa/test_play.py @@ -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) +