def test_can_get_ps3_title(self): """Can I successfully retrieve the score for Steins;Gate (the only ps3 game)""" #game_name should be the title of any game from the url game_name = "Steins;Gate" url = "http://www.metacritic.com/game/playstation-3" returned_resp = MetacriticParser.get_title_ps3_scores(game_name) returned_data = returned_resp.data.decode() decoded_json = json.loads(returned_data) returned_name = decoded_json['title'] self.assertTrue(returned_name==game_name)
def test_invalid_ps3_title(self): """Verify correct behavior when asking for an invalid PS3 title""" #game_name should be the title of any game from the url game_name = "Transistor 2" url = "http://www.metacritic.com/game/playstation-3" exep = "" try: returned_resp = MetacriticParser.get_title_ps3_scores(game_name) except: exep = sys.exc_info()[0] exep = str(exep) self.assertTrue(exep=="<class 'werkzeug.exceptions.NotFound'>")