Exemplo n.º 1
0
    def test_box_scores_for_01_01_2017(self):
        page = DailyLeadersPage(
            html=html.fromstring(self.january_29_2017_daily_leaders))
        parsed_box_score = self.player_box_scores_parser.parse(
            page.daily_leaders)
        self.assertEqual(len(parsed_box_score), 170)

        first_box_score = parsed_box_score[0]

        self.assertEqual(first_box_score["slug"], "millspa01")
        self.assertEqual(first_box_score["name"], "Paul Millsap")
        self.assertEqual(first_box_score["team"], Team.ATLANTA_HAWKS)
        self.assertEqual(first_box_score["opponent"], Team.NEW_YORK_KNICKS)
        self.assertEqual(first_box_score["outcome"], Outcome.WIN)
        self.assertEqual(first_box_score["seconds_played"], 3607)
        self.assertEqual(first_box_score["made_field_goals"], 13)
        self.assertEqual(first_box_score["attempted_field_goals"], 29)
        self.assertEqual(first_box_score["made_three_point_field_goals"], 3)
        self.assertEqual(first_box_score["attempted_three_point_field_goals"],
                         8)
        self.assertEqual(first_box_score["made_free_throws"], 8)
        self.assertEqual(first_box_score["attempted_free_throws"], 10)
        self.assertEqual(first_box_score["offensive_rebounds"], 8)
        self.assertEqual(first_box_score["defensive_rebounds"], 11)
        self.assertEqual(first_box_score["assists"], 7)
        self.assertEqual(first_box_score["steals"], 1)
        self.assertEqual(first_box_score["blocks"], 0)
        self.assertEqual(first_box_score["turnovers"], 3)
        self.assertEqual(first_box_score["personal_fouls"], 4)
        self.assertEqual(first_box_score["game_score"], 31.3)
def player_box_scores(day, month, year):
    url = '{BASE_URL}/friv/dailyleaders.cgi?month={month}&day={day}&year={year}'.format(
        BASE_URL=BASE_URL,
        day=day,
        month=month,
        year=year
    )

    response = requests.get(url=url, allow_redirects=False)

    response.raise_for_status()

    if response.status_code == requests.codes.ok:
        page = DailyLeadersPage(html=html.fromstring(response.content))
        box_score_parser = PlayerBoxScoresParser(
            team_abbreviation_parser=TeamAbbreviationParser(
                abbreviations_to_teams=TEAM_ABBREVIATIONS_TO_TEAM
            ),
            location_abbreviation_parser=LocationAbbreviationParser(
                abbreviations_to_locations=LOCATION_ABBREVIATIONS_TO_POSITION
            ),
            outcome_abbreviation_parser=OutcomeAbbreviationParser(
                abbreviations_to_outcomes=OUTCOME_ABBREVIATIONS_TO_OUTCOME
            ),
            seconds_played_parser=SecondsPlayedParser(),
        )
        return box_score_parser.parse(page.daily_leaders)

    raise InvalidDate(day=day, month=month, year=year)
Exemplo n.º 3
0
 def test_parses_blank_value_for_andrew_bogut_on_12_12_2017(self):
     page = DailyLeadersPage(
         html=html.fromstring(self.december_12_2017_daily_leaders))
     parsed_box_score = self.player_box_scores_parser.parse(
         page.daily_leaders)
     andrew_bogut = parsed_box_score[128]
     self.assertEqual(andrew_bogut["made_three_point_field_goals"], 0)
     self.assertEqual(andrew_bogut["attempted_three_point_field_goals"], 0)
Exemplo n.º 4
0
    def test_parses_new_orleans_hornets_for_box_scores_for_11_03_2003(self):
        page = DailyLeadersPage(
            html=html.fromstring(self.november_03_2003_daily_leaders))
        parsed_box_score = self.player_box_scores_parser.parse(
            page.daily_leaders)

        self.assertEqual(len(parsed_box_score), 145)

        pj_brown = parsed_box_score[51]

        self.assertEqual(pj_brown["slug"], "brownpj01")
        self.assertEqual(pj_brown["name"], "P.J. Brown")
        self.assertEqual(pj_brown["team"], Team.NEW_ORLEANS_HORNETS)
Exemplo n.º 5
0
    def player_box_scores(self, day, month, year):
        url = '{BASE_URL}/friv/dailyleaders.cgi?month={month}&day={day}&year={year}'.format(
            BASE_URL=HTTPService.BASE_URL, day=day, month=month, year=year)

        response = requests.get(url=url, allow_redirects=False)

        response.raise_for_status()

        if response.status_code == requests.codes.ok:
            page = DailyLeadersPage(html=html.fromstring(response.content))
            return self.parser.parse_player_box_scores(
                box_scores=page.daily_leaders)

        raise InvalidDate(day=day, month=month, year=year)
Exemplo n.º 6
0
    def test_parses_new_orleans_oklahoma_city_hornets_for_box_scores_for_11_01_2006(
            self):
        page = DailyLeadersPage(
            html=html.fromstring(self.november_01_2006_daily_leaders))
        parsed_box_score = self.player_box_scores_parser.parse(
            page.daily_leaders)
        self.assertEqual(len(parsed_box_score), 272)

        chris_paul = parsed_box_score[10]

        self.assertEqual(chris_paul["slug"], "paulch01")
        self.assertEqual(chris_paul["name"], "Chris Paul")
        self.assertEqual(chris_paul["team"],
                         Team.NEW_ORLEANS_OKLAHOMA_CITY_HORNETS)
Exemplo n.º 7
0
 def test_box_scores_for_12_12_2017(self):
     page = DailyLeadersPage(
         html=html.fromstring(self.december_12_2017_daily_leaders))
     parsed_box_score = self.player_box_scores_parser.parse(
         page.daily_leaders)
     self.assertEqual(len(parsed_box_score), 149)