Skip to content

Commit

Permalink
Merge branch 'test-run-action-with-no-action'
Browse files Browse the repository at this point in the history
  • Loading branch information
padawin committed Apr 16, 2016
2 parents 31dbed8 + b15ab2f commit bdebbca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/Rpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, debug=False):
self._savedGame = None
self._player = player()
self._debug = debug
self._action = []
self._action = None
fight.fight.stopFight()
area.resetChangedAreas()
container.resetChangedContainers()
Expand Down Expand Up @@ -102,6 +102,8 @@ def _runAction(self, renderJson=False):
raise core.exception.exception(_('ERROR_SAVED_GAME_NEEDED_TO_RUN_ACTION'))
elif not self._player.isConnected():
raise core.exception.exception(_('ERROR_CONNECTED_PLAYER_NEEDED_FOR_COMMAND'))
elif self._action is None:
raise core.exception.exception(_('ERROR_NO_ACTION_SET'))

try:
c = command_factory.factory.create(
Expand All @@ -110,6 +112,8 @@ def _runAction(self, renderJson=False):
self._savedGame['id_saved_game']
)

self._action = None

if c == command_factory.quit:
return c

Expand Down
5 changes: 5 additions & 0 deletions tests/core/testRpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ def test_command_with_no_player(self):
with self.assertRaises(core.exception.exception) as raised:
rpgEngine._runAction(True)
self.assertEquals(str(raised.exception), _('ERROR_CONNECTED_PLAYER_NEEDED_FOR_COMMAND'))

def test_run_action_with_no_action(self):
with self.assertRaises(core.exception.exception) as raised:
self.rpg._runAction()
self.assertEquals(str(raised.exception), _('ERROR_NO_ACTION_SET'))

0 comments on commit bdebbca

Please sign in to comment.