Пример #1
0
    def test_Retrieve_numeric_publisher(self):
        """Make sure that games with numeric fields that are expected to be strings (e.g. Publisher) are
        handled correctly"""
        """Make sure that games with multiple genres are handled correctly"""
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/Games/ByGameName?filter%5Bplatform%5D=10&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=Syphon+Filter&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
                      json=self._loadJsonFromFile('thegamesdb_search_syphon_playstation.json'),
                      status=200)

        responses.add(responses.GET, 'https://api.thegamesdb.net/Genres',
                      json=self._loadJsonFromFile('genres.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Developers',
                      json=self._loadJsonFromFile('developers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Publishers',
                      json=self._loadJsonFromFile('publishers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Games/Images',
                      json=self._loadJsonFromFile('images_syphon_playstation.json'), status=200)

        scraper = TheGamesDB_Scraper()

        #do a search to store the found results
        scraper.search('Syphon Filter', 'PlayStation')

        result = scraper.retrieve('7808', 'PlayStation')

        self.assertEqual(u"989", result['Publisher'][0], "Expected publisher with numeric name to be a string")
Пример #2
0
    def test_retrieve_missing_properties(self):

        responses.add(responses.GET,
                      'https://api.thegamesdb.net/Games/ByGameName?filter%5Bplatform%5D=4911&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=Arkanoid&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
                      json=self._loadJsonFromFile('thegamesdb_search_arkanoid_amiga.json'),
                      status=200)

        responses.add(responses.GET, 'https://api.thegamesdb.net/Genres',
                      json=self._loadJsonFromFile('genres.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Developers',
                      json=self._loadJsonFromFile('developers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Publishers',
                      json=self._loadJsonFromFile('publishers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Games/Images',
                      json=self._loadJsonFromFile('images_arkanoid_amiga.json'), status=200)

        scraper = TheGamesDB_Scraper()

        #do a search to store the found results
        scraper.search('Arkanoid', 'Amiga')

        result = scraper.retrieve('9580', 'Amiga')

        self.assertIsInstance(result, dict, "Return value of parseGameResult should be a dict")
        self.assertEquals(result['Game'], ["Arkanoid"])
        self.assertEquals(result['Developer'], ["Taito Corporation"])
        self.assertEquals(result['Publisher'], ["Discovery"])
        self.assertEquals(result['Players'], [None])
        self.assertTrue(result['Description'][0].startswith(
            "The original Breakout concept involves controlling a bat at the bottom of the screen"))
Пример #3
0
    def test_retrieve_missing_images(self):
        """Make sure that when image types are not present that we don't have issues"""
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/Games/ByGameName?filter%5Bplatform%5D=4911&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=Arkanoid&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
                      json=self._loadJsonFromFile('thegamesdb_search_arkanoid_amiga.json'),
                      status=200)

        responses.add(responses.GET, 'https://api.thegamesdb.net/Genres',
                      json=self._loadJsonFromFile('genres.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Developers',
                      json=self._loadJsonFromFile('developers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Publishers',
                      json=self._loadJsonFromFile('publishers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Games/Images',
                      json=self._loadJsonFromFile('images_arkanoid_amiga.json'), status=200)

        scraper = TheGamesDB_Scraper()

        #do a search to store the found results
        scraper.search('Arkanoid', 'Amiga')

        result = scraper.retrieve('9580', 'Amiga')

        self.assertEqual(result['Filetypeboxfront'], ['https://cdn.thegamesdb.net/images/large/boxart/front/9580-1.jpg'])
        self.assertEqual(result['Filetypeclearlogo'], ['https://cdn.thegamesdb.net/images/large/clearlogo/9580.png'])
Пример #4
0
    def test_retrieve(self):
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/Games/ByGameName?filter%5Bplatform%5D=10&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=Tekken&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
                      json=self._loadJsonFromFile('thegamesdb_search_tekken_playstation.json'),
                      status=200)

        responses.add(responses.GET,'https://api.thegamesdb.net/Genres',
                      json=self._loadJsonFromFile('genres.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Developers',
                      json=self._loadJsonFromFile('developers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Publishers',
                      json=self._loadJsonFromFile('publishers.json'), status=200)
        responses.add(responses.GET, 'https://api.thegamesdb.net/Games/Images',
                      json=self._loadJsonFromFile('images_tekken.json'), status=200)

        scraper = TheGamesDB_Scraper()

        #do a search to store the found results
        scraper.search('Tekken', 'PlayStation')

        result = scraper.retrieve('2613', 'PlayStation')

        self.assertEquals(result['Game'], [u'Tekken 2'])
        self.assertTrue(result['Description'][0].startswith('MORE THAN A SEQUEL. THE UNDISPUTED #1 FIGHTING GAME ON THE PLANET.'))
        self.assertEquals(result['Developer'], [u'Namco'])
        self.assertEquals(result['Publisher'], [u'Namco'])
        self.assertEquals(result['ReleaseYear'], [u'1996'])
        self.assertEquals(result['Genre'], [u'Fighting'])
        self.assertEquals(result['Players'], [2])

        self.assertEquals(result['Filetypeclearlogo'], [u'https://cdn.thegamesdb.net/images/large/clearlogo/2613.png'])
        self.assertEquals(result['Filetypefanart'],  [u'https://cdn.thegamesdb.net/images/large/fanart/2613-1.jpg'])
        self.assertEquals(result['Filetypescreenshot'], [u'https://cdn.thegamesdb.net/images/large/screenshots/2613-1.jpg'])
        self.assertEquals(result['Filetypeboxfront'], [u'https://cdn.thegamesdb.net/images/large/boxart/front/2613-1.png'])
        self.assertEquals(result['Filetypeboxback'], [u'https://cdn.thegamesdb.net/images/large/boxart/back/2613-1.jpg'])
Пример #5
0
 def test_GetPlatformTheGamesDB(self):
     scraper = TheGamesDB_Scraper()
     platform = scraper.get_platform_for_scraper('PlayStation')
     self.assertEqual(
         platform, "Sony Playstation",
         "Did not get expected platform name for {0} scraper".format(
             scraper.name))
Пример #6
0
    def test_Retrieve(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'thegamesdb_getgame.xml')
        scraper = TheGamesDB_Scraper()
        with open(f) as xmlfile:
            data = xmlfile.read()
        result = scraper._parseGameResult(data)
        self.assertIsInstance(
            result, dict, "Return value of parseGameResult should be a dict")
        self.assertEqual(result['Game'], ["Tekken 2"],
                         "Expected game name value to be set")
        self.assertEqual(result['Publisher'], ["Namco"],
                         "Expected publisher value to be set")
        self.assertTrue(
            result['Description'][0].startswith(
                "MORE THAN A SEQUEL. THE UNDISPUT"),
            "Expected description value to be set")

        self.assertEqual(result['ReleaseYear'], ["1996"],
                         "Expected year = 1996 from test XML")
        self.assertEqual(result['Players'], ["2"],
                         "Expected 2 players in test XML")
        self.assertEqual(len(result['Genre']), 1,
                         "Expected 1 genre from test XML")
        self.assertEqual(result['Genre'], ["Fighting"],
                         "Expected Fighting genre in test XML")
Пример #7
0
    def test_search_online(self):
        scraper = TheGamesDB_Scraper()
        result = scraper.search('No Game Found', 'PlayStation')

        #game = scraper.retrieve('7808', 'PlayStation')

        """
Пример #8
0
    def test_GamesResultWithUnicode(self):
        scraper = TheGamesDB_Scraper()
        gamedata = scraper.retrieve('137')

        self.assertTrue(
            u"Mushroom Kingdom while avoiding all of Kamek\u2019s clever traps"
            in gamedata['Description'][0],
            "Expected non-ASCII strings to be converted to Unicode")
 def test_GamesListNoResults(self):
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'thegamesdb_getgameslist_noresults.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     results = scraper._parseSearchResults(data)
     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_GamesListResultsBS(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'thegamesdb_getgameslist.xml')
        scraper = TheGamesDB_Scraper()

        with open(f) as xmlfile:
            data = xmlfile.read()
        results = scraper._parseSearchResultsBS(data)

        # Expect 3 results
        self.assertEqual(len(results), 3, "Number of search results for BeautifulSoup parser multiple search match did not match expected number")
 def test_RetrieveGameWithNumericPublisher(self):
     """Make sure that games with numeric fields that are expected to be strings (e.g. Publisher) are
     handled correctly"""
     # Ref http://thegamesdb.net/api/GetGame.php?id=7808"  # Syphon Filter, Publisher 989
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                      'scraper_web_responses', 'thegamesdb_getgame_2genres.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResult(data)
     self.assertEqual(u"989", result['Publisher'][0], "Expected publisher with numeric name to be a string")
Пример #12
0
    def test_get_images(self):

        images = self._loadJsonFromFile('images_tekken.json')
        scraper = TheGamesDB_Scraper()
        result = scraper._parse_image_result(images, '2613')

        self.assertEquals(result['Filetypeclearlogo'], [u'https://cdn.thegamesdb.net/images/large/clearlogo/2613.png'])
        self.assertEquals(result['Filetypefanart'], [u'https://cdn.thegamesdb.net/images/large/fanart/2613-1.jpg'])
        self.assertEquals(result['Filetypescreenshot'], [u'https://cdn.thegamesdb.net/images/large/screenshots/2613-1.jpg'])
        self.assertEquals(result['Filetypeboxfront'], [u'https://cdn.thegamesdb.net/images/large/boxart/front/2613-1.png'])
        self.assertEquals(result['Filetypeboxback'], [u'https://cdn.thegamesdb.net/images/large/boxart/back/2613-1.jpg'])
 def test_RetrieveBS(self):
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'thegamesdb_getgame.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResultBS(data)
     self.assertIsInstance(result, dict, "Return value of parseGameResult should be a dict")
     self.assertEqual(result['publisher'], "Namco", "Expected publisher value to be set")
     self.assertTrue(result['description'].startswith("MORE THAN A SEQUEL. THE UNDISPUT"), "Expected description value to be set")
     self.assertEqual(len(result['genres']), 1, "Expected 1 genre from test XML")
     self.assertEqual(result['year'], '1996', "Expected year = 1996 from test XML")
 def test_RetrieveMissingProperties(self):
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'thegamesdb_getgame_missingproperties.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResult(data)
     self.assertIsInstance(result, dict, "Return value of parseGameResult should be a dict")
     self.assertEqual(result['Game'], ["Arkanoid"], "Expected game name value to be set")
     self.assertEqual(result['Developer'], ["Taito"], "Expected developer value to be set")
     self.assertEqual(result['Publisher'], ["Discovery"], "Expected publisher value to be set")
     self.assertTrue(result['Description'][0].startswith("The original Breakout concept involves controlling a bat at the bottom of the screen"), "Expected description value to be set")
    def test_GamesListResultsNonAscii(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'thegamesdb_getgameslist_nonascii.xml')
        scraper = TheGamesDB_Scraper()

        with open(f) as xmlfile:
            data = xmlfile.read()
        results = scraper._parseSearchResults(data)

        # Expect 289 valid results out of 303 entries
        self.assertEqual(len(results), 289, "Number of search results for multiple search match did not match expected number")
    def test_RetrieveImagesWhenNotPresent(self):
        """Make sure that when image types are not present (fanart in this example) that we don't have issues"""
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'thegamesdb_getgame_missingartwork.xml')
        scraper = TheGamesDB_Scraper()
        with open(f) as xmlfile:
            data = xmlfile.read()
        result = scraper._parseGameResult(data)

        self.assertEqual(result['Filetypeboxfront'], ['http://thegamesdb.net/banners/boxart/original/front/291-1.jpg'])
        self.assertEqual(result['Filetypeboxback'], ['http://thegamesdb.net/banners/boxart/original/back/291-1.jpg'])
        self.assertEqual(result['Filetypescreenshot'], ['http://thegamesdb.net/banners/screenshots/291-1.jpg'])
 def test_RetrieveGameWithMultipleGenres(self):
     """Make sure that games with multiple genres are handled correctly"""
     # Ref http://thegamesdb.net/api/GetGame.php?id=7808"  # Syphon Filter, Publisher 989
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                      'scraper_web_responses', 'thegamesdb_getgame_2genres.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResult(data)
     self.assertEqual(len(result['Genre']), 2)
     self.assertIn("Action", result['Genre'], "Expected genre Action to be retrieved")
     self.assertIn("Stealth", result['Genre'], "Expected genre Stealth to be retrieved")
    def test_RetrieveImages(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata',
                         'scraper_web_responses', 'thegamesdb_getgame.xml')
        scraper = TheGamesDB_Scraper()
        with open(f) as xmlfile:
            data = xmlfile.read()
        result = scraper._parseGameResult(data)

        self.assertEqual(result['Filetypefanart'], ['http://thegamesdb.net/banners/fanart/original/2613-1.jpg'])
        self.assertEqual(result['Filetypeboxfront'], ['http://thegamesdb.net/banners/boxart/original/front/2613-1.png'])
        self.assertEqual(result['Filetypeboxback'], ['http://thegamesdb.net/banners/boxart/original/back/2613-1.jpg'])
        self.assertEqual(result['Filetypescreenshot'], ['http://thegamesdb.net/banners/screenshots/2613-1.jpg'])
Пример #19
0
 def test_GamesListNoResults(self):
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                      'tests', 'testdata', 'scraper_web_responses',
                      'thegamesdb_getgameslist_noresults.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     results = scraper._parseSearchResults(data)
     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")
Пример #20
0
    def test_search(self):
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/Games/ByGameName?filter%5Bplatform%5D=10&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=Tekken&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
                      json=self._loadJsonFromFile('thegamesdb_search_tekken_playstation.json'),
                      status=200)

        scraper = TheGamesDB_Scraper()

        results = scraper.search('Tekken', 'PlayStation')

        # Expect 5 results
        self.assertEqual(len(results), 5, "Number of search results for multiple search match did not match expected number")
        self.assertEqual(len(scraper.resultdata), 5, "Number of search results for multiple search match did not match expected number")
Пример #21
0
    def test_search_no_results(self):
        """Make sure that games with multiple genres are handled correctly"""
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/Games/ByGameName?filter%5Bplatform%5D=10&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=No+Game+Found&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
                      json=self._loadJsonFromFile('thegamesdb_search_no_result.json'),
                      status=200)

        scraper = TheGamesDB_Scraper()

        #do a search to store the found results
        results = scraper.search('No Game Found', 'PlayStation')

        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")
Пример #22
0
 def test_RetrieveGameWithNumericPublisher(self):
     """Make sure that games with numeric fields that are expected to be strings (e.g. Publisher) are
     handled correctly"""
     # Ref http://thegamesdb.net/api/GetGame.php?id=7808"  # Syphon Filter, Publisher 989
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                      'tests', 'testdata', 'scraper_web_responses',
                      'thegamesdb_getgame_2genres.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResult(data)
     self.assertEqual(
         u"989", result['Publisher'][0],
         "Expected publisher with numeric name to be a string")
Пример #23
0
    def test_GamesListResultsBS(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'thegamesdb_getgameslist.xml')
        scraper = TheGamesDB_Scraper()

        with open(f) as xmlfile:
            data = xmlfile.read()
        results = scraper._parseSearchResultsBS(data)

        # Expect 3 results
        self.assertEqual(
            len(results), 3,
            "Number of search results for BeautifulSoup parser multiple search match did not match expected number"
        )
    def test_Retrieve(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'tests', 'testdata', 'scraper_web_responses', 'thegamesdb_getgame.xml')
        scraper = TheGamesDB_Scraper()
        with open(f) as xmlfile:
            data = xmlfile.read()
        result = scraper._parseGameResult(data)
        self.assertIsInstance(result, dict, "Return value of parseGameResult should be a dict")
        self.assertEqual(result['Game'], ["Tekken 2"], "Expected game name value to be set")
        self.assertEqual(result['Publisher'], ["Namco"], "Expected publisher value to be set")
        self.assertTrue(result['Description'][0].startswith("MORE THAN A SEQUEL. THE UNDISPUT"), "Expected description value to be set")

        self.assertEqual(result['ReleaseYear'], ["1996"], "Expected year = 1996 from test XML")
        self.assertEqual(result['Players'], ["2"], "Expected 2 players in test XML")
        self.assertEqual(len(result['Genre']), 1, "Expected 1 genre from test XML")
        self.assertEqual(result['Genre'], ["Fighting"], "Expected Fighting genre in test XML")
Пример #25
0
    def test_GamesListResultsNonAscii(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'thegamesdb_getgameslist_nonascii.xml')
        scraper = TheGamesDB_Scraper()

        with open(f) as xmlfile:
            data = xmlfile.read()
        results = scraper._parseSearchResults(data)

        # Expect 289 valid results out of 303 entries
        self.assertEqual(
            len(results), 289,
            "Number of search results for multiple search match did not match expected number"
        )
Пример #26
0
 def test_RetrieveGameWithMultipleGenres(self):
     """Make sure that games with multiple genres are handled correctly"""
     # Ref http://thegamesdb.net/api/GetGame.php?id=7808"  # Syphon Filter, Publisher 989
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                      'tests', 'testdata', 'scraper_web_responses',
                      'thegamesdb_getgame_2genres.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResult(data)
     self.assertEqual(len(result['Genre']), 2)
     self.assertIn("Action", result['Genre'],
                   "Expected genre Action to be retrieved")
     self.assertIn("Stealth", result['Genre'],
                   "Expected genre Stealth to be retrieved")
Пример #27
0
    def test_RetrieveImagesWhenNotPresent(self):
        """Make sure that when image types are not present (fanart in this example) that we don't have issues"""
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'thegamesdb_getgame_missingartwork.xml')
        scraper = TheGamesDB_Scraper()
        with open(f) as xmlfile:
            data = xmlfile.read()
        result = scraper._parseGameResult(data)

        self.assertEqual(
            result['Filetypeboxfront'],
            ['http://thegamesdb.net/banners/boxart/original/front/291-1.jpg'])
        self.assertEqual(
            result['Filetypeboxback'],
            ['http://thegamesdb.net/banners/boxart/original/back/291-1.jpg'])
        self.assertEqual(
            result['Filetypescreenshot'],
            ['http://thegamesdb.net/banners/screenshots/291-1.jpg'])
Пример #28
0
 def test_RetrieveBS(self):
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                      'tests', 'testdata', 'scraper_web_responses',
                      'thegamesdb_getgame.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResultBS(data)
     self.assertIsInstance(
         result, dict, "Return value of parseGameResult should be a dict")
     self.assertEqual(result['publisher'], "Namco",
                      "Expected publisher value to be set")
     self.assertTrue(
         result['description'].startswith(
             "MORE THAN A SEQUEL. THE UNDISPUT"),
         "Expected description value to be set")
     self.assertEqual(len(result['genres']), 1,
                      "Expected 1 genre from test XML")
     self.assertEqual(result['year'], '1996',
                      "Expected year = 1996 from test XML")
Пример #29
0
 def test_RetrieveMissingProperties(self):
     f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                      'tests', 'testdata', 'scraper_web_responses',
                      'thegamesdb_getgame_missingproperties.xml')
     scraper = TheGamesDB_Scraper()
     with open(f) as xmlfile:
         data = xmlfile.read()
     result = scraper._parseGameResult(data)
     self.assertIsInstance(
         result, dict, "Return value of parseGameResult should be a dict")
     self.assertEqual(result['Game'], ["Arkanoid"],
                      "Expected game name value to be set")
     self.assertEqual(result['Developer'], ["Taito"],
                      "Expected developer value to be set")
     self.assertEqual(result['Publisher'], ["Discovery"],
                      "Expected publisher value to be set")
     self.assertTrue(
         result['Description'][0].startswith(
             "The original Breakout concept involves controlling a bat at the bottom of the screen"
         ), "Expected description value to be set")
Пример #30
0
    def test_RetrieveImages(self):
        f = os.path.join(os.path.dirname(__file__), '..', '..', 'resources',
                         'tests', 'testdata', 'scraper_web_responses',
                         'thegamesdb_getgame.xml')
        scraper = TheGamesDB_Scraper()
        with open(f) as xmlfile:
            data = xmlfile.read()
        result = scraper._parseGameResult(data)

        self.assertEqual(
            result['Filetypefanart'],
            ['http://thegamesdb.net/banners/fanart/original/2613-1.jpg'])
        self.assertEqual(
            result['Filetypeboxfront'],
            ['http://thegamesdb.net/banners/boxart/original/front/2613-1.png'])
        self.assertEqual(
            result['Filetypeboxback'],
            ['http://thegamesdb.net/banners/boxart/original/back/2613-1.jpg'])
        self.assertEqual(
            result['Filetypescreenshot'],
            ['http://thegamesdb.net/banners/screenshots/2613-1.jpg'])
Пример #31
0
    def test_retrieve_multiple_genres(self):
        """Make sure that games with multiple genres are handled correctly"""
        responses.add(
            responses.GET,
            'https://api.thegamesdb.net/v1/Games/ByGameName?filter%5Bplatform%5D=10&apikey=1e821bf1bab06854840650d77e7e2248f49583821ff9191f2cced47e43bf0a73&include=boxart&name=Syphon+Filter&fields=id%2Cgame_title%2Crelease_date%2Cdevelopers%2Cpublishers%2Cplayers%2Cgenres%2Coverview%2Crating',
            json=self._loadJsonFromFile(
                'thegamesdb_search_syphon_playstation.json'),
            status=200)

        responses.add(responses.GET,
                      'https://api.thegamesdb.net/v1/Genres',
                      json=self._loadJsonFromFile('genres.json'),
                      status=200)
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/v1/Developers',
                      json=self._loadJsonFromFile('developers.json'),
                      status=200)
        responses.add(responses.GET,
                      'https://api.thegamesdb.net/v1/Publishers',
                      json=self._loadJsonFromFile('publishers.json'),
                      status=200)
        responses.add(
            responses.GET,
            'https://api.thegamesdb.net/v1/Games/Images',
            json=self._loadJsonFromFile('images_syphon_playstation.json'),
            status=200)

        scraper = TheGamesDB_Scraper()

        #do a search to store the found results
        scraper.search('Syphon Filter', 'PlayStation')

        result = scraper.retrieve('7808', 'PlayStation')

        self.assertEqual(len(result['Genre']), 2)
        self.assertIn("Action", result['Genre'],
                      "Expected genre Action to be retrieved")
        self.assertIn("Stealth", result['Genre'],
                      "Expected genre Stealth to be retrieved")
	def test_GetPlatformTheGamesDB(self):
		scraper = TheGamesDB_Scraper()
		platform = scraper.get_platform_for_scraper('PlayStation')
		self.assertEqual(platform, "Sony Playstation", "Did not get expected platform name for {0} scraper".format(scraper.name))
    def test_GamesResultWithUnicode(self):
        scraper = TheGamesDB_Scraper()
        gamedata = scraper.retrieve('137')

        self.assertTrue(u"Mushroom Kingdom while avoiding all of Kamek\u2019s clever traps" in gamedata['Description'][0],
                        "Expected non-ASCII strings to be converted to Unicode")