Esempio n. 1
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")
 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_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")
    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_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'])
 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")
Esempio n. 7
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")
    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")
Esempio n. 9
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")
Esempio n. 10
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'])
Esempio n. 11
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")
Esempio n. 12
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'])