Example #1
0
def test_error_draft(pick_number='BC', round_number='Van', year=2020):
    """
    Test function to check that it handles erroneoss inputs
    to the function.

    Keyword Arguments:
        pick_number {str} -- erroneoss pick_number to query (default: {'BC'})
        round_number {str} --
            erroneoss round_number to query (default: {'Van'})
        year {int} -- year out of range to query (default: {2020})
    """
    # Test that the pick number type is correct
    with pytest.raises(Exception) as e:
        assert pypuck.draft_pick(pick_number, round_number, year)
    assert str(e.value) == ("Expecting <class 'int'> got <class 'str'> "
                            "for pick_number")
    # Test that the round number type is correct
    with pytest.raises(Exception) as e:
        pick_number = 1
        assert pypuck.draft_pick(pick_number, round_number, year)
    assert str(e.value) == ("Expecting <class 'int'> got <class 'str'> "
                            "for round_number")
    # Test that the round number can't be 0.
    with pytest.raises(Exception) as e:
        pick_number = 1
        round_number = 0
        assert pypuck.draft_pick(pick_number, round_number, year)
    assert str(e.value) == "Number of round is out of avaliable range"
    # Test that the year is correct type
    with pytest.raises(Exception) as e:
        pick_number = 1
        round_number = 1
        year = '2020'
        assert pypuck.draft_pick(pick_number, round_number, year)
    assert str(e.value) == "Expecting <class 'int'> got <class 'str'> for year"
Example #2
0
def test_drafted_person():
    """
    Test the draft function with default inputs.

    Raises:
        ValueError: A message if the returned value is wrong.
    """
    draft = pypuck.draft_pick(pick_number=1, round_number=2, year=2000)
    if draft['playerName'].values != 'Ilya Nikulin':
        raise ValueError('draft_pick() returned erroroneous information '
                         'about specified parameters')
Example #3
0
def test_default_draft(pick_number=1):
    """
    Test function to check that draft_pick function returns
    correct information with default parameters.

    Keyword Arguments:
        pick_number {int} -- default pick_number to query (default: {'1'})
    """
    draft = pypuck.draft_pick(pick_number=1)
    if draft.shape != (554, 5):
        raise ValueError('draft_pick() returned erroneous '
                         'information about specified parameters')
Example #4
0
def test_draft(pick_number=1, round_number=2, year=2000):
    """
    Test function to check proper inputs and returns.

    Keyword Arguments:
        pick_number {int} -- pick_number to query (default: {1})
        round_number {int} -- round_number to query (default: {2})
        year {int} -- year to query (default: {2020})

    Raises:
        ValueError: A message if return value is wrong (not enough data).
    """
    if len(pypuck.draft_pick(pick_number, round_number, year)) != 1:
        raise ValueError('draft_pick() returned incorrect information, \
                there can`t be more than 1 person for specified parameters')