def test_can_get_ps4_title(self): """Can I successfully retrieve the score for a top 10 game?""" #game_name should be the title of any game from the url game_name = "The Witcher 3: Wild Hunt" url = "http://www.metacritic.com/game/playstation-4" returned_resp = MetacriticParser.get_title_ps4_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_ps4_title(self): """Verify correct behavior when asking for an invalid PS4 title""" #game_name should be the title of any game from the url game_name = "Transistor 2" url = "http://www.metacritic.com/game/playstation-4" exep = "" try: returned_resp = MetacriticParser.get_title_ps4_scores(game_name) except: exep = sys.exc_info()[0] exep = str(exep) self.assertTrue(exep=="<class 'werkzeug.exceptions.NotFound'>")