def test_DownloadGameWithSpecialCharactersReturnsResults(self):
     """GiantBomb doesn't handle searching games with special characters well, so we need to strip any suffix
     metadata from the gamename before we search"""
     scraper = GiantBomb_Scraper()
     results = scraper.search("Super Mario World (USA)", "SNES")
     print "{0}".format(results)
     self.assertTrue(len(results) > 0, "Expected more than 1 result for Super Mario World")
Exemple #2
0
 def test_GetPlatformGiantBomb(self):
     scraper = GiantBomb_Scraper()
     platform = scraper.get_platform_for_scraper('PlayStation')
     self.assertEqual(
         platform, "22",
         "Did not get expected platform name for {0} scraper".format(
             scraper.name))
    def test_retrieve_release(self):

        responses.add(
            responses.GET,
            'https://www.giantbomb.com/api/release/3050-80827/?api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&format=json',
            json=self._loadJsonFromFile('giantbomb_getrelease.json'),
            status=200)

        responses.add(
            responses.GET,
            'https://www.giantbomb.com/api/game/12298/?api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&format=json',
            json=self._loadJsonFromFile('giantbomb_getgame.json'),
            status=200)

        scraper = GiantBomb_Scraper()
        result = scraper.retrieve('3050-80827', 'PlayStation')

        self.assertEquals(result['Publisher'][0],
                          'Sony Interactive Entertainment Europe')
        self.assertEquals(
            result['Filetypeboxfront'][0],
            'https://www.giantbomb.com/api/image/scale_large/691211-wipeout3.png'
        )
        self.assertEquals(result['Game'][0], 'WipEout 3')
        self.assertEquals(result['ReleaseYear'][0], '1999')
        self.assertEquals(result['Genre'][0], 'Driving/Racing')
        self.assertEquals(result['Developer'][0], 'Psygnosis Limited')
Exemple #4
0
 def test_DownloadGameWithSpecialCharactersReturnsResults(self):
     """GiantBomb doesn't handle searching games with special characters well, so we need to strip any suffix
     metadata from the gamename before we search"""
     scraper = GiantBomb_Scraper()
     results = scraper.search("Super Mario World (USA)", "SNES")
     print("{0}".format(results))
     self.assertTrue(
         len(results) > 0,
         "Expected more than 1 result for Super Mario World")
    def test_ErrorResponseInvalidApiKey(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'giantbomb_error_invalidapikey.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()

        with self.assertRaises(ScraperExceededAPIQuoteException):
            scraper._check_status_code(json.loads(data)['status_code'])
    def test_GamesListNoResults(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'giantbomb_getgameslist_noresults.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_search_results(json.loads(data))

        # Expect 0 results and an empty list
        self.assertIsInstance(results, list, "Expected search results to return list even if no results found")
        self.assertEqual(len(results), 0, "Empty search results should return empty list")
    def test_parse_release_result(self):
        
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'giantbomb_getrelease.json')
        scraper = GiantBomb_Scraper()
        with open(f) as jsonfile:
            data = jsonfile.read()
        result = scraper._parse_release_result(json.loads(data)['results'])

        self.assertEqual(result['id'], 12298, "Incorrect game ID")
        self.assertEqual(result['Filetypeboxfront'][0], "https://www.giantbomb.com/api/image/scale_large/691211-wipeout3.png", "Incorrect image")
Exemple #8
0
    def test_ErrorResponseInvalidApiKey(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_error_invalidapikey.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()

        with self.assertRaises(ScraperExceededAPIQuoteException):
            scraper._check_status_code(json.loads(data)['status_code'])
 def test_search_release(self):                
     
     responses.add(responses.GET, 
             'https://www.giantbomb.com/api/releases?filter=platform%3A22%2Cname%3AWip3out&api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&field_list=id%2Cguid%2Cname%2Crelease_date&format=json',
             json=self._loadJsonFromFile('giantbomb_getreleaselist.json'), 
             status=200)
     
     scraper = GiantBomb_Scraper()
     result = scraper.search('Wip3out', 'PlayStation')
     
     self.assertEquals(result[0]['title'], 'Wip3out')
     self.assertEquals(result[0]['id'], '3050-80827')
 def test_search_release(self):                
     
     responses.add(responses.GET,
             'https://www.giantbomb.com/api/releases?filter=platform%3A22%2Cname%3AWip&api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&field_list=id%2Cguid%2Cname%2Crelease_date&format=json',
             json=self._loadJsonFromFile('giantbomb_getreleaselist.json'), 
             status=200)
     
     scraper = GiantBomb_Scraper()
     result = scraper.search('Wip3out', 'PlayStation')
     
     self.assertEquals(result[0]['title'], 'Wip3out')
     self.assertEquals(result[0]['id'], '3050-80827')
    def test_GamesListResults(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'giantbomb_getgameslist.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_search_results(json.loads(data))

        # Expect 10 results per page (regardless of total)
        self.assertEqual(len(results), 10, "Number of search results for multiple search match did not match expected number")
        self.assertEqual(results[0]['title'], "Super Mario World 2: Yoshi's Island", "Incorrect description for first result")
        self.assertEqual(results[0]['id'], 2866, "Incorrect game ID for first result")
        self.assertEqual(results[0]['releaseDate'], "1995", "Incorrect releaseDate for first result")
Exemple #12
0
    def test_parse_release_result(self):

        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_getrelease.json')
        scraper = GiantBomb_Scraper()
        with open(f) as jsonfile:
            data = jsonfile.read()
        result = scraper._parse_release_result(json.loads(data)['results'])

        self.assertEqual(result['id'], 12298, "Incorrect game ID")
        self.assertEqual(
            result['Filetypeboxfront'][0],
            "https://www.giantbomb.com/api/image/scale_large/691211-wipeout3.png",
            "Incorrect image")
 def test_parse_search_results(self):
     
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                      'scraper_web_responses', 'giantbomb_getreleaselist.json')
     scraper = GiantBomb_Scraper()
     with open(f) as jsonfile:
         data = jsonfile.read()
     results = scraper._parse_search_results(json.loads(data))
     
     # Expect 10 results per page (regardless of total)
     self.assertEqual(len(results), 2, "Number of search results for multiple search match did not match expected number")
     self.assertEqual(results[0]['title'], "Wip3out", "Incorrect description for first result")
     self.assertEqual(results[0]['id'], '3050-80827', "Incorrect game ID for first result")
     self.assertEqual(results[0]['releaseDate'], "1999", "Incorrect releaseDate for first result")
     self.assertEqual(results[0]['SearchKey'][0], "Wip3out", "Incorrect SearchKey for first result")
Exemple #14
0
    def test_GamesListNoResults(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_getgameslist_noresults.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_search_results(json.loads(data))

        # Expect 0 results and an empty list
        self.assertIsInstance(
            results, list,
            "Expected search results to return list even if no results found")
        self.assertEqual(len(results), 0,
                         "Empty search results should return empty list")
    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 #17
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'])
 def test_retrieve_release(self):                
     
     responses.add(responses.GET, 
             'https://www.giantbomb.com/api/release/3050-80827/?api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&format=json',
             json=self._loadJsonFromFile('giantbomb_getrelease.json'), 
             status=200)
     
     responses.add(responses.GET, 
             'https://www.giantbomb.com/api/game/12298/?api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&format=json',
             json=self._loadJsonFromFile('giantbomb_getgame.json'), 
             status=200)
     
     scraper = GiantBomb_Scraper()
     result = scraper.retrieve('3050-80827', 'PlayStation')
     
     self.assertEquals(result['Publisher'][0], 'Sony Interactive Entertainment Europe')
     self.assertEquals(result['Filetypeboxfront'][0], 'https://www.giantbomb.com/api/image/scale_large/691211-wipeout3.png')
     self.assertEquals(result['Game'][0], 'WipEout 3')
     self.assertEquals(result['ReleaseYear'][0], '1999')
     self.assertEquals(result['Genre'][0], 'Driving/Racing')
     self.assertEquals(result['Developer'][0], 'Psygnosis Limited')
Exemple #19
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")
Exemple #20
0
    def test_GamesListResults(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_getgameslist.json')
        scraper = GiantBomb_Scraper()

        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_search_results(json.loads(data))

        # Expect 10 results per page (regardless of total)
        self.assertEqual(
            len(results), 10,
            "Number of search results for multiple search match did not match expected number"
        )
        self.assertEqual(results[0]['title'],
                         "Super Mario World 2: Yoshi's Island",
                         "Incorrect description for first result")
        self.assertEqual(results[0]['id'], 2866,
                         "Incorrect game ID for first result")
        self.assertEqual(results[0]['releaseDate'], "1995",
                         "Incorrect releaseDate for first result")
Exemple #21
0
    def test_parse_search_results(self):

        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'giantbomb', 'giantbomb_getreleaselist.json')
        scraper = GiantBomb_Scraper()
        with open(f) as jsonfile:
            data = jsonfile.read()
        results = scraper._parse_search_results(json.loads(data))

        # Expect 10 results per page (regardless of total)
        self.assertEqual(
            len(results), 2,
            "Number of search results for multiple search match did not match expected number"
        )
        self.assertEqual(results[0]['title'], "Wip3out",
                         "Incorrect description for first result")
        self.assertEqual(results[0]['id'], '3050-80827',
                         "Incorrect game ID for first result")
        self.assertEqual(results[0]['releaseDate'], "1999",
                         "Incorrect releaseDate for first result")
        self.assertEqual(results[0]['SearchKey'][0], "Wip3out",
                         "Incorrect SearchKey for first result")
	def test_GetPlatformGiantBomb(self):
		scraper = GiantBomb_Scraper()
		platform = scraper.get_platform_for_scraper('PlayStation')
		self.assertEqual(platform, "22", "Did not get expected platform name for {0} scraper".format(scraper.name))