예제 #1
0
 def test_convert_title_teams(self):
     # Successful
     self.assertEqual(
         convert_title_teams("St. Louis Rams at Seattle Seahawks"),
         ("SEA", "STL"))
     self.assertEqual(
         convert_title_teams("Baltimore Ravens vs. New York Giants"),
         ("NYG", "BAL"))
     # Failure
     self.assertRaises(KeyError, convert_title_teams, "Rams at Seahawks")
     self.assertRaises(ValueError, convert_title_teams,
                       "St. Louis Rams @ Seattle Seahawks")
 def test_convert_title_teams(self):
     # Successful
     self.assertEqual(
             convert_title_teams("St. Louis Rams at Seattle Seahawks"),
             ("SEA", "STL")
             )
     self.assertEqual(
             convert_title_teams("Baltimore Ravens vs. New York Giants"),
             ("NYG", "BAL")
             )
     # Failure
     self.assertRaises(
             KeyError, convert_title_teams, "Rams at Seahawks"
             )
     self.assertRaises(
             ValueError, convert_title_teams,
             "St. Louis Rams @ Seattle Seahawks"
             )
예제 #3
0
 def __parse_title(self):
     """ Parse the title tag from the HTML. This sets the two teams and the
     date."""
     soup = self.soups["title"]
     text = soup.find("title").get_text(strip=True)
     teams = text.split('-')[0]
     fulldate = text.split('-')[1]
     # Parse teams to codes
     (home, away) = convert_title_teams(teams)
     self.json["home team"] = home
     self.home_team = home
     self.json["away team"] = away
     self.away_team = away
     # Parse time
     self.json["datetime"]["date"] = convert_title_date(fulldate)
     self.season = get_season(fulldate)
     self.output_date = get_output_date(fulldate)
 def __parse_title(self):
     """ Parse the title tag from the HTML. This sets the two teams and the
     date."""
     soup = self.soups["title"]
     text = soup.find("title").get_text(strip=True)
     teams = text.split('-')[0]
     fulldate = text.split('-')[1]
     # Parse teams to codes
     (home, away) = convert_title_teams(teams)
     self.json["home team"] = home
     self.home_team = home
     self.json["away team"] = away
     self.away_team = away
     # Parse time
     self.json["datetime"]["date"] = convert_title_date(fulldate)
     self.season = get_season(fulldate)
     self.output_date = get_output_date(fulldate)