def test_convert_title_date(self): # Successful self.assertEqual(convert_title_date("January 2nd, 2012"), "2012-01-02") # Failure self.assertRaises(ValueError, convert_title_date, "February 45th, 2001") self.assertRaises(ValueError, convert_title_date, "Notober 21nd, 2012") self.assertRaises(ValueError, convert_title_date, "October 21teen, 2012")
def test_convert_title_date(self): # Successful self.assertEqual(convert_title_date("January 2nd, 2012"), "2012-01-02") # Failure self.assertRaises( ValueError, convert_title_date, "February 45th, 2001" ) self.assertRaises( ValueError, convert_title_date, "Notober 21nd, 2012" ) self.assertRaises( ValueError, convert_title_date, "October 21teen, 2012" )
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)