def test_RetrieveGameWithMultipleGenres(self):
        """Make sure that games with multiple genres are handled correctly"""
        # Ref https://www.giantbomb.com/api/game/3030-17123/?api_key=API_KEY&format=json&resources=game
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'giantbomb_getgame_2genres.json')
        scraper = GiantBomb_Scraper()
        with open(f) as jsonfile:
            data = jsonfile.read()
        result = scraper._parse_game_result(json.loads(data)['results'])
        self.assertEqual(len(result['Genre']), 2)
        self.assertIn("Action", result['Genre'], "Expected genre Action to be retrieved")
        self.assertIn("Platformer", result['Genre'], "Expected genre Platformer to be retrieved")

        self.assertEqual(len(result['Publisher']), 2)
        self.assertIn("Ubisoft S.A.", result['Publisher'], "Expected publisher Ubisoft S.A. to be retrieved")
        self.assertIn("Enix Corporation", result['Publisher'], "Expected publisher Enix Corporation to be retrieved")
    def test_GameResult(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'giantbomb_getgame.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_game_result(json.loads(data)['results'])
        print "Game result is {0}".format(results)

        # FIXME TODO Do we have a double-list, or just a single one?
        self.assertEquals(results['Developer'], ['Psygnosis Limited', 'The Designers Republic'])
        self.assertEquals(results['Publisher'], ['Sony Interactive Entertainment Europe'])
        self.assertEquals(results['ReleaseYear'], ['1999'])

        # Genres
        self.assertEquals(results['Genre'], ['Driving/Racing'])
Exemple #3
0
    def test_GameResult(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_getgame.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_game_result(json.loads(data)['results'])
        print("Game result is {0}".format(results))

        # FIXME TODO Do we have a double-list, or just a single one?
        self.assertEquals(results['Developer'],
                          ['Psygnosis Limited', 'The Designers Republic'])
        self.assertEquals(results['Publisher'],
                          ['Sony Interactive Entertainment Europe'])
        self.assertEquals(results['ReleaseYear'], ['1999'])

        # Genres
        self.assertEquals(results['Genre'], ['Driving/Racing'])
Exemple #4
0
    def test_RetrieveGameWithMultipleGenres(self):
        """Make sure that games with multiple genres are handled correctly"""
        # Ref https://www.giantbomb.com/api/game/3030-17123/?api_key=API_KEY&format=json&resources=game
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_getgame_2genres.json')
        scraper = GiantBomb_Scraper()
        with open(f) as jsonfile:
            data = jsonfile.read()
        result = scraper._parse_game_result(json.loads(data)['results'])
        self.assertEqual(len(result['Genre']), 2)
        self.assertIn("Action", result['Genre'],
                      "Expected genre Action to be retrieved")
        self.assertIn("Platformer", result['Genre'],
                      "Expected genre Platformer to be retrieved")

        self.assertEqual(len(result['Publisher']), 2)
        self.assertIn("Ubisoft S.A.", result['Publisher'],
                      "Expected publisher Ubisoft S.A. to be retrieved")
        self.assertIn("Enix Corporation", result['Publisher'],
                      "Expected publisher Enix Corporation to be retrieved")