Exemple #1
0
    def test_invalid_url_returns_none(self, *args, **kwargs):
        mock_id = PropertyMock(return_value='BAD')
        player = Player(None)
        type(player)._player_id = mock_id

        result = player._retrieve_html_page()

        assert result is None
Exemple #2
0
    def test_correct_initial_index_found(self):
        seasons = ['2017-18', 'Career', '2016-17']
        mock_season = mock.PropertyMock(return_value=seasons)
        player = Player('carsen-edwards-1')
        type(player)._season = mock_season

        result = player._find_initial_index()

        assert player._index == 1
Exemple #3
0
    def test_player_with_no_weight_returns_none(self):
        mock_weight = PropertyMock(return_value=None)
        player = Player(None)
        type(player)._weight = mock_weight

        result = player.weight

        assert result is None
Exemple #4
0
    def test_no_float_returns_default_value_player_class(self):
        mock_player_efficiency_rating = PropertyMock(return_value=[''])
        mock_index = PropertyMock(return_value=0)
        player = Player(None)
        type(player)._player_efficiency_rating = mock_player_efficiency_rating
        type(player)._index = mock_index

        result = player.player_efficiency_rating

        assert result is None
Exemple #5
0
    def test_no_int_return_default_value_player_class(self):
        mock_games = PropertyMock(return_value=[''])
        mock_index = PropertyMock(return_value=0)
        player = Player(None)
        type(player)._games_played = mock_games
        type(player)._index = mock_index

        result = player.games_played

        assert result is None
Exemple #6
0
    def test_no_float_returns_default_value_abstract_class(self):
        mock_percentage = PropertyMock(return_value=[''])
        mock_index = PropertyMock(return_value=0)
        player = Player(None)
        type(player)._field_goal_percentage = mock_percentage
        type(player)._index = mock_index

        result = player.field_goal_percentage

        assert result is None
Exemple #7
0
    def test_no_int_return_default_value_abstract_class(self):
        mock_field_goals = PropertyMock(return_value=[''])
        mock_index = PropertyMock(return_value=0)
        player = Player(None)
        type(player)._field_goals = mock_field_goals
        type(player)._index = mock_index

        result = player.field_goals

        assert result is None
Exemple #8
0
    def test_player_with_no_stats(self):
        player = Player(None)
        result = player._combine_season_stats(None, None, {})

        assert result == {}
Exemple #9
0
    def setup_method(self, *args, **kwargs):
        self.results_career = {
            'assist_percentage': 17.3,
            'assists': 166,
            'block_percentage': 0.6,
            'blocks': 11,
            'box_plus_minus': 6.1,
            'conference': '',
            'defensive_box_plus_minus': 1.9,
            'defensive_rebound_percentage': 11.8,
            'defensive_rebounds': 206,
            'defensive_win_shares': 3.5,
            'effective_field_goal_percentage': 0.515,
            'field_goal_attempts': 835,
            'field_goal_percentage': 0.428,
            'field_goals': 357,
            'free_throw_attempt_rate': 0.279,
            'free_throw_attempts': 233,
            'free_throw_percentage': 0.798,
            'free_throws': 186,
            'games_played': 72,
            'games_started': 58,
            'height': '6-1',
            'minutes_played': 1905,
            'name': 'Carsen Edwards',
            'offensive_box_plus_minus': 4.2,
            'offensive_rebound_percentage': 1.8,
            'offensive_rebounds': 27,
            'offensive_win_shares': 4.4,
            'personal_fouls': 133,
            'player_efficiency_rating': 19.9,
            'points': 1046,
            'points_produced': 961,
            'position': 'Guard',
            'season': 'Career',
            'steal_percentage': 2.4,
            'steals': 78,
            'team_abbreviation': 'purdue',
            'three_point_attempt_rate': 0.459,
            'three_point_attempts': 383,
            'three_point_percentage': 0.381,
            'three_pointers': 146,
            'total_rebound_percentage': 7.2,
            'total_rebounds': 233,
            'true_shooting_percentage': 0.553,
            'turnover_percentage': 11.9,
            'turnovers': 128,
            'two_point_attempts': 452,
            'two_point_percentage': 0.467,
            'two_pointers': 211,
            'usage_percentage': 28.9,
            'weight': 190,
            'win_shares': 8.0,
            'win_shares_per_40_minutes': 0.167
        }

        self.results_2018 = {
            'assist_percentage': 19.5,
            'assists': 104,
            'block_percentage': 0.8,
            'blocks': 8,
            'box_plus_minus': 9.0,
            'conference': 'big-ten',
            'defensive_box_plus_minus': 1.5,
            'defensive_rebound_percentage': 12.9,
            'defensive_rebounds': 129,
            'defensive_win_shares': 2.0,
            'effective_field_goal_percentage': 0.555,
            'field_goal_attempts': 500,
            'field_goal_percentage': 0.458,
            'field_goals': 229,
            'free_throw_attempt_rate': 0.318,
            'free_throw_attempts': 159,
            'free_throw_percentage': 0.824,
            'free_throws': 131,
            'games_played': 37,
            'games_started': 37,
            'height': '6-1',
            'minutes_played': 1092,
            'name': 'Carsen Edwards',
            'offensive_box_plus_minus': 7.6,
            'offensive_rebound_percentage': 1.5,
            'offensive_rebounds': 13,
            'offensive_win_shares': 4.0,
            'personal_fouls': 65,
            'player_efficiency_rating': 25.4,
            'points': 686,
            'points_produced': 626,
            'position': 'Guard',
            'season': '2017-18',
            'steal_percentage': 2.3,
            'steals': 42,
            'team_abbreviation': 'purdue',
            'three_point_attempt_rate': 0.478,
            'three_point_attempts': 239,
            'three_point_percentage': 0.406,
            'three_pointers': 97,
            'total_rebound_percentage': 7.7,
            'total_rebounds': 142,
            'true_shooting_percentage': 0.596,
            'turnover_percentage': 10.0,
            'turnovers': 64,
            'two_point_attempts': 261,
            'two_point_percentage': 0.506,
            'two_pointers': 132,
            'usage_percentage': 30.5,
            'weight': 190,
            'win_shares': 6.1,
            'win_shares_per_40_minutes': 0.223
        }

        self.player = Player('carsen-edwards-1')