Beispiel #1
0
 def test_get_output_date(self):
     # Successful
     self.assertEqual(get_output_date("January 2nd, 2012"), "20120102")
     # Failure
     self.assertRaises(ValueError, get_output_date, "February 45th, 2001")
     self.assertRaises(ValueError, get_output_date, "Notober 21nd, 2012")
     self.assertRaises(ValueError, get_output_date, "October 21teen, 2012")
 def test_get_output_date(self):
     # Successful
     self.assertEqual(get_output_date("January 2nd, 2012"), "20120102")
     # Failure
     self.assertRaises(
             ValueError, get_output_date, "February 45th, 2001"
             )
     self.assertRaises(
             ValueError, get_output_date, "Notober 21nd, 2012"
             )
     self.assertRaises(
             ValueError, get_output_date, "October 21teen, 2012"
             )
Beispiel #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)