"""Test the game_logic module of PA1.

Author: YOUR NAME
Version: THE DATE
"""

from game_logic import get_valid_items, check_spot_status, has_empty_space, \
    check_line, check_valid_letter, check_no_repetition_in_block, \
    check_valid_move, check_completion_status


def test_get_valid_items():
    assert get_valid_items(4) == ['A', 'B', 'C', 'D']


def test_check_spot_status():
    board = [None, 'A',
             None, 'B']
    assert check_spot_status(board, 0)
    assert not check_spot_status(board, 1)


def test_has_empty_space():
    board = [None, 'A',
             None, 'B']
    assert has_empty_space(board)
    board = ['C', 'A',
             'B', 'D']
    assert not has_empty_space(board)


def test_check_line():
    line = [None, 'A', None, 'B']
    assert check_line(line)
    line = [None, 'A', None, 'A']
    assert not check_line(line)


def test_check_valid_letter():
    valid_items = ['A', 'B', 'C', 'D']
    assert check_valid_letter('A', valid_items)
    assert not check_valid_letter('E', valid_items)


def test_check_valid_move():
    board = [None, 'A', 'C', None,
             None, 'B', 'D', None,
             None, 'C', 'A', None,
             None, 'D', 'B', None]
    assert check_valid_move('A', 0, board) == 1
    assert check_valid_move('D', 0, board) == 0


def test_check_completion_status():
    board = ['A']
    assert check_completion_status(board)
    board = [None, 'A', 'C', None,
             None, 'B', 'D', None,
             None, 'C', 'A', None,
             None, 'D', 'B', None]
    assert not check_completion_status(board)


if __name__ == "__main__":
    import pytest
    pytest.main(["-q", __file__])
