# Path: tests/helpers.py
# class StubBoard(object):
#     def __init__(self):
#         self._cells = [[None for j in xrange(8)] for i in xrange(8)]
#         self.enpassant = None
# 
#     def __getitem__(self, pos):
#         row, col = pos
#         return self._cells[row][col]
# 
#     def __setitem__(self, pos, piece):
#         row, col = pos
#         self._cells[row][col] = piece
# 
#     def is_empty(self, pos):
#         return self[pos] is None
# 
#     def is_enpassant(self, pos):
#         enp = self.enpassant
#         return enp and enp[0] == pos[0] and enp[1] == pos[1]
# 
# class StubPiece(object):
#     def __init__(self, board, team, position):
#         self.board = board
#         self.team = team
#         self.position = position
# 
# def C(pos):
#     row = int(pos[1]) - 1
#     col = POS[pos[0]]
#     return row, col
# 
# WHITE = 1
# 
# BLACK = -1


import unittest
from .helpers import StubBoard, StubPiece, C, WHITE, BLACK
        from chess.models import Pawn

        pawn = self.get_pawn(board, BLACK, C('g4'))
        result = pawn.is_valid_move(C('g5'))
        self.assertFalse(result)

    def test_invalid_2forward(self):
        board = StubBoard()
        pawn = self.get_pawn(board, WHITE, C('d2'))
        pawn.move_to(C('d4'))
        result = pawn.is_valid_move(C('d6'))
        self.assertFalse(result)

        pawn = self.get_pawn(board, BLACK, C('d6'))
        pawn.move_to(C('d5'))
        result = pawn.is_valid_move(C('d3'))
        self.assertFalse(result)

    def test_invalid_sameposition(self):
        board = StubBoard()
        pawn = self.get_pawn(board, WHITE, C('d2'))
        result = pawn.is_valid_move(C('d2'))
        self.assertFalse(result)

        pawn = self.get_pawn(board, BLACK, C('d2'))
        result = pawn.is_valid_move(C('d2'))
        self.assertFalse(result)
    # -------------------------------------------------------------------------


if __name__ == '__main__':

# Path: tests/helpers.py
# class StubBoard(object):
#     def __init__(self):
#         self._cells = [[None for j in xrange(8)] for i in xrange(8)]
#         self.enpassant = None
# 
#     def __getitem__(self, pos):
#         row, col = pos
#         return self._cells[row][col]
# 
#     def __setitem__(self, pos, piece):
#         row, col = pos
#         self._cells[row][col] = piece
# 
#     def is_empty(self, pos):
#         return self[pos] is None
# 
#     def is_enpassant(self, pos):
#         enp = self.enpassant
#         return enp and enp[0] == pos[0] and enp[1] == pos[1]
# 
# class StubPiece(object):
#     def __init__(self, board, team, position):
#         self.board = board
#         self.team = team
#         self.position = position
# 
# def C(pos):
#     row = int(pos[1]) - 1
#     col = POS[pos[0]]
#     return row, col
# 
# WHITE = 1
# 
# BLACK = -1


# Path: tests/test_pawn_movement.py
import unittest
from .helpers import StubBoard, StubPiece, C, WHITE, BLACK
        from chess.models import Pawn


        pawn = self.get_pawn(board, BLACK, C('g4'))
        result = pawn.is_valid_move(C('g5'))
        self.assertFalse(result)

    def test_invalid_2forward(self):
        board = StubBoard()
        pawn = self.get_pawn(board, WHITE, C('d2'))
        pawn.move_to(C('d4'))
        result = pawn.is_valid_move(C('d6'))
        self.assertFalse(result)

        pawn = self.get_pawn(board, BLACK, C('d6'))
        pawn.move_to(C('d5'))
        result = pawn.is_valid_move(C('d3'))
        self.assertFalse(result)

    def test_invalid_sameposition(self):
        board = StubBoard()
        pawn = self.get_pawn(board, WHITE, C('d2'))
        result = pawn.is_valid_move(C('d2'))
        self.assertFalse(result)

        pawn = self.get_pawn(board, BLACK, C('d2'))
        result = pawn.is_valid_move(C('d2'))
        self.assertFalse(result)
    # -------------------------------------------------------------------------


if __name__ == '__main__':

    unittest.main()