def update_artwork(self): log.info('update_artwork') control = self.getControlById(CONTROL_LIST_ROMCOLLECTIONS) selected_romcollection_name = control.getSelectedItem().getLabel() romcollection_id = 0 #32120 = All if selected_romcollection_name != util.localize(32120): romcollection = self.gui.config.getRomCollectionByName( selected_romcollection_name) romcollection_id = romcollection.id control = self.getControlById(CONTROL_LIST_ARTWORKTYPES) selected_filetype_name = control.getSelectedItem().getLabel() filetype_id = 0 #32120 = All if selected_filetype_name != util.localize(32120): filetype, errormessage = self.gui.config.get_filetype_by_name( selected_filetype_name, self.gui.config.tree) filetype_id = filetype.id progressDialog = dialogprogress.ProgressDialogGUI() #32950 = Scan Artwork progressDialog.create(util.localize(32950)) updater = ArtworkUpdater(progressDialog, self.gui.gdb, self.gui.config) updater.update_artwork_cache(romcollection_id, filetype_id)
def test_cache_artwork_1_rom_collection_n_artworktypes_add_artwork(self): # Load a config file with 2 valid RomCollections and all FileTypes and ImagePlacings config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() # image should be missing at start game = GameView(self.gdb).getGameById(5) self.assertIsNone( game[GameView.COL_fileType1], "fileType1 expected to be missing before update artwork cache") self.assertIsNone( game[GameView.COL_fileType4], "fileType1 expected to be missing before update artwork cache") rcid = 1 artwork_type = 0 ArtworkUpdater(RCBMockGui(), self.gdb, conf).update_artwork_cache(rcid, artwork_type) # image should be available now game = GameView(self.gdb).getGameById(5) self.assertEquals("./testdata/artwork/Amiga/boxfront/Eliminator.png", game[GameView.COL_fileType1]) self.assertEquals("./testdata/artwork/Amiga/screenshot/Eliminator.png", game[GameView.COL_fileType4])
def test_cache_artwork_n_rom_collections_n_artworktypes_add_remove_artwork( self): # Load a config file with 2 valid RomCollections and all FileTypes and ImagePlacings config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() #check for correct startup values game = GameView(self.gdb).getGameById(5) self.assertIsNone( game[GameView.COL_fileType1], "fileType1 expected to be missing before update artwork cache") self.assertIsNone( game[GameView.COL_fileType4], "fileType4 expected to be missing before update artwork cache") game = GameView(self.gdb).getGameById(9) self.assertIsNotNone( game[GameView.COL_fileType4], "fileType4 expected to be present before update artwork cache") rcid = 0 artwork_type = 0 ArtworkUpdater(RCBMockGui(), self.gdb, conf).update_artwork_cache(rcid, artwork_type) # image should be available now game = GameView(self.gdb).getGameById(5) self.assertEquals("./testdata/artwork/Amiga/boxfront/Eliminator.png", game[GameView.COL_fileType1]) self.assertEquals("./testdata/artwork/Amiga/screenshot/Eliminator.png", game[GameView.COL_fileType4]) # image should be removed now game = GameView(self.gdb).getGameById(9) self.assertIsNone( game[GameView.COL_fileType4], "fileType4 expected to be removed after update artwork cache") self.assertIsNone( game[GameView.COL_fileType6], "fileType6 expected to be removed after update artwork cache") #available artwork should still be present game = GameView(self.gdb).getGameById(7) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Adventure (1980) (Atari).jpg", game[GameView.COL_fileType4]) game = GameView(self.gdb).getGameById(8) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).gif", game[GameView.COL_fileType4])
def test_cache_artwork_1_rom_collection_1_artworktype_remove_artwork(self): # Load a config file with 2 valid RomCollections and all FileTypes and ImagePlacings config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() # image should be present at start game = GameView(self.gdb).getGameById(9) self.assertIsNotNone( game[GameView.COL_fileType4], "fileType4 expected to be present before update artwork cache") rcid = 2 artwork_type = 4 ArtworkUpdater(RCBMockGui(), self.gdb, conf).update_artwork_cache(rcid, artwork_type) # image should be removed now game = GameView(self.gdb).getGameById(9) self.assertIsNone( game[GameView.COL_fileType4], "fileType4 expected to be removed after update artwork cache") #other artwork types should be unchanged self.assertEquals( "./testdata/artwork/Atari 2600/video/Asteroids (1981) (Atari) [no copyright].png", game[GameView.COL_fileType6]) #available artwork should still be present game = GameView(self.gdb).getGameById(7) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Adventure (1980) (Atari).jpg", game[GameView.COL_fileType4]) game = GameView(self.gdb).getGameById(8) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).gif", game[GameView.COL_fileType4])