def test_convert_vegas_line(self):
     # Successful
     self.assertEqual(convert_vegas_line("Arizona Cardinals -9.0"), ("ARI", -9))
     self.assertEqual(convert_vegas_line("New York Giants -19.5"), ("NYG", -19.5))
     # Failure raises various errors
     self.assertRaises(IndexError, convert_vegas_line, "Minnesota Vikings 10.5")
     self.assertRaises(IndexError, convert_vegas_line, "San Diego Chargers +4.5")
     self.assertRaises(ValueError, convert_vegas_line, "San Diego Chargers -four")
     self.assertRaises(KeyError, convert_vegas_line, "Pallet Town Charizards -10.")
Ejemplo n.º 2
0
 def test_convert_vegas_line(self):
     # Successful
     self.assertEqual(convert_vegas_line("Arizona Cardinals -9.0"),
                      ("ARI", -9))
     self.assertEqual(convert_vegas_line("New York Giants -19.5"),
                      ("NYG", -19.5))
     # Failure raises various errors
     self.assertRaises(IndexError, convert_vegas_line,
                       "Minnesota Vikings 10.5")
     self.assertRaises(IndexError, convert_vegas_line,
                       "San Diego Chargers +4.5")
     self.assertRaises(ValueError, convert_vegas_line,
                       "San Diego Chargers -four")
     self.assertRaises(KeyError, convert_vegas_line,
                       "Pallet Town Charizards -10.")
Ejemplo n.º 3
0
 def __parse_game_info(self):
     """ Set up the game info dictionary and add it to self.json """
     soup = self.soups["game_info"]
     # Find each row of the table
     rows = soup.find_all("tr")
     for row in rows:
         # Find each column of the table
         cols = row.find_all("td")
         if cols:  # This if removes the header
             # Extract the key and value
             tmp_key = cols[0].get_text(strip=True)
             tmp_value = cols[1].get_text(strip=True)
             if tmp_key == "Stadium":
                 (stad, dome) = convert_stadium(tmp_value)
                 self.json["venue"]["stadium"] = stad
                 self.json["venue"]["dome"] = dome
             elif tmp_key == "Start Time":
                 self.json["datetime"]["start time"] = convert_time(
                     tmp_value)
             elif tmp_key == "Surface":
                 self.json["venue"]["surface"] = tmp_value
             elif tmp_key == "Duration":
                 self.json["datetime"]["duration"] = convert_duration(
                     tmp_value)
             elif tmp_key == "Attendance":
                 # We need to replace commas for int to work
                 self.json["venue"]["attendance"] = int(
                     tmp_value.replace(',', ''))
             elif tmp_key == "Weather":
                 self.json["weather"] = convert_weather(tmp_value)
             elif tmp_key == "Vegas Line":
                 (team_code, line) = convert_vegas_line(tmp_value)
                 self.json["betting"]["spread"] = line
                 if team_code == self.home_team:
                     self.json["betting"]["winner"] = "home"
                 elif team_code == self.away_team:
                     self.json["betting"]["winner"] = "away"
                 else:  # We use None when no team is favored
                     self.json["betting"]["winner"] = None
             elif tmp_key == "Over/Under":
                 self.json["betting"]["over under"] = convert_overunder(
                     tmp_value)
 def __parse_game_info(self):
     """ Set up the game info dictionary and add it to self.json """
     soup = self.soups["game_info"]
     # Find each row of the table
     rows = soup.find_all("tr")
     for row in rows:
         # Find each column of the table
         cols = row.find_all("td")
         if cols:  # This if removes the header
             # Extract the key and value
             tmp_key = cols[0].get_text(strip=True)
             tmp_value = cols[1].get_text(strip=True)
             if tmp_key == "Stadium":
                 (stad, dome) = convert_stadium(tmp_value)
                 self.json["venue"]["stadium"] = stad
                 self.json["venue"]["dome"] = dome
             elif tmp_key == "Start Time":
                 self.json["datetime"]["start time"] = convert_time(tmp_value)
             elif tmp_key == "Surface":
                 self.json["venue"]["surface"] = tmp_value
             elif tmp_key == "Duration":
                 self.json["datetime"]["duration"] = convert_duration(tmp_value)
             elif tmp_key == "Attendance":
                 # We need to replace commas for int to work
                 self.json["venue"]["attendance"] = int(tmp_value.replace(',', ''))
             elif tmp_key == "Weather":
                 self.json["weather"] = convert_weather(tmp_value)
             elif tmp_key == "Vegas Line":
                 (team_code, line) = convert_vegas_line(tmp_value)
                 self.json["betting"]["spread"] = line
                 if team_code == self.home_team:
                     self.json["betting"]["winner"] = "home"
                 elif team_code == self.away_team:
                     self.json["betting"]["winner"] = "away"
                 else:  # We use None when no team is favored
                     self.json["betting"]["winner"] = None
             elif tmp_key == "Over/Under":
                 self.json["betting"]["over under"] = convert_overunder(tmp_value)