#!/usr/bin/python

try:
    import mock
except ImportError:
    from unittest import mock

from .context import powerball
from powerball.player import Player


class TestPlayerClass:

    def test_init_with_all_arguments_none(self):

        player = Player()

        assert player.first_name == None
        assert player.last_name == None
        assert player.numbers == []

    def test_init_with_all_arguments_not_none(self):

        first_name = "Foo"
        last_name = "Bar"
        numbers = [1, 2, 3, 4, 5, 6]

        player = Player(first_name, last_name, numbers)

        assert player.first_name == first_name
        assert player.last_name == last_name
        assert player.numbers == numbers

    @mock.patch('builtins.input', side_effect=['Foo'])
    def test_get_name_with_valid_input_foo_non_blank(self, input):
    
        name = Player._get_name('name_type')
        assert name == 'Foo'
    
    @mock.patch('builtins.input', side_effect=['', '   ', '\n', 'Foo'])
    def test_get_name_with_invalid_inputs_blank_spaces_newline(self, input):
        """
        multiple inputs are provided, since initial invalid
        inputs will result in next promt until valid value is entered.
        """

        name = Player._get_name('name_type')
        assert name == 'Foo'

    def test_is_valid_number_with_valid_wb_15(self):

        number = 15
        number_list = [10, 20]

        valid = Player.is_valid_number(number, number_list)

        assert valid == True

    def test_is_valid_number_with_valid_wb_1_lower_limit(self):

        number = 1
        number_list = [10, 20]

        valid = Player.is_valid_number(number, number_list)

        assert valid == True

    def test_is_valid_number_with_valid_wb_69_upper_limit(self):

        number = 69
        number_list = [10, 20]

        valid = Player.is_valid_number(number, number_list)

        assert valid == True

    def test_is_valid_number_with_valid_pb_15(self):

        number = 15
        number_list = [10, 20, 30, 40, 50]

        valid = Player.is_valid_number(number, number_list)

        assert valid == True

    def test_is_valid_number_with_valid_pb_1_lower_limit(self):

        number = 1
        number_list = [10, 20, 30, 40, 50]

        valid = Player.is_valid_number(number, number_list)

        assert valid == True

    def test_is_valid_number_with_valid_pb_26_upper_limit(self):

        number = 26
        number_list = [10, 20, 30, 40, 50]

        valid = Player.is_valid_number(number, number_list)

        assert valid == True

@@ -2535,28 +2535,1340 @@
        assert valid == True%0A
+%0A    def test_is_valid_number_with_invalid_wb_15_repeated(self):%0A%0A        number = 15%0A        number_list = %5B10, 15%5D%0A%0A        valid = Player.is_valid_number(number, number_list)%0A%0A        assert valid == False%0A%0A    def test_is_valid_number_with_invalid_wb_X_not_a_number(self):%0A%0A        number = 'X'%0A        number_list = %5B10, 15%5D%0A%0A        valid = Player.is_valid_number(number, number_list)%0A%0A        assert valid == False%0A%0A    def test_is_valid_number_with_invalid_wb_0_lower_then_limit(self):%0A%0A        number = 0%0A        number_list = %5B10, 15%5D%0A%0A        valid = Player.is_valid_number(number, number_list)%0A%0A        assert valid == False%0A%0A    def test_is_valid_number_with_invalid_wb_70_higher_then_limit(self):%0A%0A        number = 70%0A        number_list = %5B10, 15%5D%0A%0A        valid = Player.is_valid_number(number, number_list)%0A%0A        assert valid == False%0A%0A    def test_is_valid_number_with_invalid_pb_0_lower_then_limit(self):%0A%0A        number = 0%0A        number_list = %5B10, 15, 20, 25, 30%5D%0A%0A        valid = Player.is_valid_number(number, number_list)%0A%0A        assert valid == False%0A%0A    def test_is_valid_number_with_invalid_pb_27_higher_then_limit(self):%0A%0A        number = 27%0A        number_list = %5B10, 15, 20, 25, 30%5D%0A%0A        valid = Player.is_valid_number(number, number_list)%0A%0A        assert valid == False%0A

add tests for is_valid_number with invalid inputs