projects
/
naja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Save player mode.
[naja.git]
/
naja
/
tests
/
test_actions.py
diff --git
a/naja/tests/test_actions.py
b/naja/tests/test_actions.py
index f590caa9e576adf99e6cb1ab9dbebd3dda15e498..d770f12397f04ffec487192ba299a8445f51a3a1 100644
(file)
--- a/
naja/tests/test_actions.py
+++ b/
naja/tests/test_actions.py
@@
-2,11
+2,15
@@
from unittest import TestCase
from naja.constants import BITS, MOVES
from naja.gameboard import GameBoard, LocationCard
from naja.constants import BITS, MOVES
from naja.gameboard import GameBoard, LocationCard
+from naja.options import parse_args
from naja.player import Player
from naja import actions
class TestActions(TestCase):
from naja.player import Player
from naja import actions
class TestActions(TestCase):
+ def setUp(self):
+ parse_args([])
+
def make_player(self, *bits):
player_bits = 0
for bit in bits:
def make_player(self, *bits):
player_bits = 0
for bit in bits:
@@
-16,7
+20,7
@@
class TestActions(TestCase):
def make_board(self, player_bits=None, locations=None):
if locations is None:
locations = [{'actions': []}]
def make_board(self, player_bits=None, locations=None):
if locations is None:
locations = [{'actions': []}]
- board = GameBoard.new_game(
locations
)
+ board = GameBoard.new_game(
{'cards': locations}
)
if player_bits is not None:
board.player.bits.bits = 0
board.player.bits.set_bits(player_bits)
if player_bits is not None:
board.player.bits.bits = 0
board.player.bits.set_bits(player_bits)
@@
-66,16
+70,16
@@
class TestActions(TestCase):
TEXT = "foo %(direction)s %(rowcol)s"
action_north = DirectionAction([], direction='NORTH')
TEXT = "foo %(direction)s %(rowcol)s"
action_north = DirectionAction([], direction='NORTH')
- self.assertEqual(action_north.get_text(), "foo
NORTH
column")
+ self.assertEqual(action_north.get_text(), "foo
{NORTH}
column")
action_south = DirectionAction([], direction='SOUTH')
action_south = DirectionAction([], direction='SOUTH')
- self.assertEqual(action_south.get_text(), "foo
SOUTH
column")
+ self.assertEqual(action_south.get_text(), "foo
{SOUTH}
column")
action_east = DirectionAction([], direction='EAST')
action_east = DirectionAction([], direction='EAST')
- self.assertEqual(action_east.get_text(), "foo
EAST
row")
+ self.assertEqual(action_east.get_text(), "foo
{EAST}
row")
action_west = DirectionAction([], direction='WEST')
action_west = DirectionAction([], direction='WEST')
- self.assertEqual(action_west.get_text(), "foo
WEST
row")
+ self.assertEqual(action_west.get_text(), "foo
{WEST}
row")
def test_DoNothing(self):
board = self.make_board()
def test_DoNothing(self):
board = self.make_board()
@@
-190,17
+194,21
@@
class TestActions(TestCase):
def test_AllowKnightMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
def test_AllowKnightMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
- actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT").perform_action(board, None)
+ actions.AllowChessMove(
+ set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT"
+ ).perform_action(board, None)
self.assertEqual(board.player.movement_mode, MOVES.KNIGHT)
self.assertEqual(board.player.movement_mode, MOVES.KNIGHT)
-
def test_AllowBishopMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
def test_AllowBishopMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
- actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP").perform_action(board, None)
+ actions.AllowChessMove(
+ set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP"
+ ).perform_action(board, None)
self.assertEqual(board.player.movement_mode, MOVES.BISHOP)
self.assertEqual(board.player.movement_mode, MOVES.BISHOP)
-
def test_AllowCastleMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
def test_AllowCastleMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
- actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE").perform_action(board, None)
+ actions.AllowChessMove(
+ set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE"
+ ).perform_action(board, None)
self.assertEqual(board.player.movement_mode, MOVES.CASTLE)
self.assertEqual(board.player.movement_mode, MOVES.CASTLE)