def test_board_remove_piece(self): board = Board(size = 2) origin = Position(0,0) foo = Foo() board.place_piece(origin, foo) self.assertEqual(board.remove_piece(origin), foo) self.assertIsNone(board.piece_at(origin))
def test_copy_of(self): board = Board(size = 3) board.place_piece(Position(0, 0), Foo()) board.place_piece(Position(1, 1), Foo()) board.place_piece(Position(2, 2), Foo()) other_board = board.copy_of() self.assertFalse(other_board is board) self.assertEqual(board, other_board)
def test_board_neq_diff_placing(self): board = Board(size = 2) board.place_piece(Position(0, 0), Foo()) board.place_piece(Position(0, 1), Bar()) other_board = Board(size = 3) other_board.place_piece(Position(0, 1), Foo()) other_board.place_piece(Position(1, 1), Bar()) self.assertNotEqual(board, other_board)
def test_board_eq_same_pieces(self): board = Board(size = 2) board.place_piece(Position(0, 0), Foo()) board.place_piece(Position(0, 1), Bar()) other_board = Board(size = 2) other_board.place_piece(Position(0, 0), Foo()) other_board.place_piece(Position(0, 1), Bar()) self.assertEqual(board, other_board)
def test_board_open_positions(self): board = Board(size = 2) board.place_piece(Position(0, 0), Foo()) board.place_piece(Position(1, 1), Foo()) expected_positions = [Position(0, 1), Position(1, 0)] actual_positions = [p for p in board.open_positions()] self.assertItemsEqual(actual_positions, expected_positions)
def test_board_place_piece_when_piece_present(self): board = Board(size = 2) origin = Position(0, 0) foo = Foo() foo2 = Foo() board.place_piece(origin, foo) with self.assertRaises(ValueError): board.place_piece(origin, foo2)
def test_board_eq_same_board(self): board = Board(size = 2) board.place_piece(Position(0, 0), Foo()) self.assertEqual(board, board)
def test_board_place_piece(self): board = Board(size = 2) origin = Position(0, 0) foo = Foo() board.place_piece(position = origin, piece = foo) self.assertEqual(board.piece_at(origin), foo)