Пример #1
0
    def test_scraping_metadata_for_game(self):

        # arrange
        settings = self.get_test_settings()

        launcher = StandardRomLauncher(None, settings, None, None, None, None,
                                       None)
        launcher.set_platform('Nintendo SNES')

        rom = ROM({'id': 1234})
        fakeRomPath = FakeFile(Test_nfo_scraper.TEST_ASSETS_DIR +
                               '\\dr_mario.zip')
        with open(Test_nfo_scraper.TEST_ASSETS_DIR + "\\dr_mario.nfo",
                  'r') as f:
            fakeRomPath.setFakeContent(f.read())

        target = NfoScraper(settings, launcher)

        # act
        actual = target.scrape_metadata('doctor mario', fakeRomPath, rom)

        # assert
        self.assertTrue(actual)
        self.assertEqual(u'Dr. Mario', rom.get_name())
        self.assertEqual(u'Puzzle', rom.get_genre())
        print(rom)
Пример #2
0
    def test_if_retroarch_launcher_will_apply_the_correct_arguments_when_running_on_android(
            self, mock_exeFactory, is_linux_mock, is_android_mock, is_win_mock,
            mock_file):

        # arrange
        is_linux_mock.return_value = False
        is_win_mock.return_value = False
        is_android_mock.return_value = True

        settings = self._get_test_settings()

        launcher_data = {}
        launcher_data['type'] = OBJ_LAUNCHER_RETROARCH
        launcher_data['id'] = 'ABC'
        launcher_data['toggle_window'] = True
        launcher_data['romext'] = None
        launcher_data['args_extra'] = None
        launcher_data['roms_base_noext'] = 'snes'
        launcher_data[
            'retro_core'] = '/data/data/com.retroarch/cores/mame_libretro_android.so'
        launcher_data[
            'retro_config'] = '/storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg'
        launcher_data['application'] = None

        rom_id = 'qqqq'
        rom = {}
        rom['id'] = 'qqqq'
        rom['m_name'] = 'TestCase'
        rom['filename'] = 'superrom.zip'
        rom['altapp'] = None
        roms = {rom_id: rom}
        json_data = json.dumps(roms,
                               ensure_ascii=False,
                               indent=1,
                               separators=(',', ':'))

        rom_dir = FakeFile(self.TEST_ASSETS_DIR)
        rom_dir.setFakeContent(json_data)

        mock = FakeExecutor()
        mock_exeFactory.create.return_value = mock
        paths = Fake_Paths('\\fake\\')
        paths.ROMS_DIR = rom_dir

        repository = ROMSetRepository(paths, settings)
        launcher = RetroarchLauncher(paths, settings, launcher_data, None,
                                     mock_exeFactory, repository, None)
        launcher.select_ROM(rom_id)

        expected = '/system/bin/am'
        expectedArgs = "start --user 0 -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.retroarch/.browser.retroactivity.RetroActivityFuture -e ROM 'superrom.zip' -e LIBRETRO /data/data/com.retroarch/cores/mame_libretro_android.so -e CONFIGFILE /storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg "

        # act
        launcher.launch()

        # assert
        self.assertEqual(expected, mock.getActualApplication().getPath())
        self.assertEqual(expectedArgs, mock.actualArgs)
Пример #3
0
    def test_if_rom_launcher_will_apply_the_correct_disc_in_a_multidisc_situation(
            self, mock_exeFactory, mock_dialog, mock_file):

        # arrange
        settings = self._get_test_settings()

        launcher_data = {}
        launcher_data['id'] = 'ABC'
        launcher_data['type'] = OBJ_LAUNCHER_ROM
        launcher_data['application'] = 'c:\\temp\\'
        launcher_data['toggle_window'] = True
        launcher_data['romext'] = ''
        launcher_data['application'] = ''
        launcher_data['args'] = '-a -b -c -d -e $rom$ -yes'
        launcher_data['args_extra'] = ''
        launcher_data['roms_base_noext'] = 'snes'

        rom = {}
        rom['id'] = 'qqqq'
        rom['m_name'] = 'TestCase'
        rom['filename'] = 'd:\\games\\discXX.zip'
        rom['altapp'] = ''
        rom['altarg'] = ''
        rom['disks'] = ['disc01.zip', 'disc02.zip']

        rom_id = rom['id']
        roms = {rom_id: rom}
        json_data = json.dumps(roms,
                               ensure_ascii=False,
                               indent=1,
                               separators=(',', ':'))

        rom_dir = FakeFile(self.TEST_ASSETS_DIR)
        rom_dir.setFakeContent(json_data)

        mock_dialog.return_value = 1
        mock = FakeExecutor()
        mock_exeFactory.create.return_value = mock

        paths = Fake_Paths('\\fake\\')
        paths.ROMS_DIR = rom_dir

        repository = ROMSetRepository(paths, settings)
        launcher = StandardRomLauncher(paths, settings, launcher_data, None,
                                       mock_exeFactory, repository, None)
        launcher.select_ROM(rom_id)

        expected = launcher_data['application']
        expectedArgs = '-a -b -c -d -e d:\\games\\disc02.zip -yes'

        # act
        launcher.launch()

        # assert
        self.assertEqual(expectedArgs, mock.actualArgs)
Пример #4
0
    def test_if_rom_launcher_will_correctly_passthrough_the_application_when_launching(
            self, mock_exeFactory, mock_file):

        # arrange
        settings = self._get_test_settings()

        launcher_data = {}
        launcher_data['id'] = 'ABC'
        launcher_data['type'] = OBJ_LAUNCHER_ROM
        launcher_data['application'] = 'path'
        launcher_data['toggle_window'] = True
        launcher_data['romext'] = ''
        launcher_data['application'] = ''
        launcher_data['args'] = '-a -b -c -d -e $rom$ -yes'
        launcher_data['args_extra'] = ''
        launcher_data['roms_base_noext'] = 'snes'

        rom_id = 'fghj'
        rom = {
            'id': rom_id,
            'm_name': 'TestCase',
            'filename': 'testing.zip',
            'altapp': '',
            'altarg': ''
        }
        roms = {rom_id: rom}
        json_data = json.dumps(roms,
                               ensure_ascii=False,
                               indent=1,
                               separators=(',', ':'))

        rom_dir = FakeFile(self.TEST_ASSETS_DIR)
        rom_dir.setFakeContent(json_data)

        mock = FakeExecutor()
        mock_exeFactory.create.return_value = mock

        paths = Fake_Paths('\\fake\\')
        paths.ROMS_DIR = rom_dir

        repository = ROMSetRepository(paths, settings)
        launcher = StandardRomLauncher(paths, settings, launcher_data, None,
                                       mock_exeFactory, repository, None)
        launcher.select_ROM(rom_id)

        expected = launcher_data['application']
        expectedArgs = '-a -b -c -d -e testing.zip -yes'

        # act
        launcher.launch()

        # assert
        self.assertIsNotNone(mock.actualApplication)
        self.assertEqual(expected, mock.actualApplication.getPath())
        self.assertEqual(expectedArgs, mock.actualArgs)
Пример #5
0
    def test_if_rom_launcher_will_use_the_multidisk_launcher_when_romdata_has_disks_field_filled_in(
            self, mock_exeFactory, mock_file):

        # arrange
        settings = self._get_test_settings()

        launcher_data = {}
        launcher_data['id'] = 'ABC'
        launcher_data['type'] = OBJ_LAUNCHER_ROM
        launcher_data['application'] = 'path'
        launcher_data['toggle_window'] = True
        launcher_data['romext'] = ''
        launcher_data['application'] = ''
        launcher_data['args'] = ''
        launcher_data['args_extra'] = ''
        launcher_data['roms_base_noext'] = 'snes'

        rom_id = 'fghj'
        rom = {
            'id': rom_id,
            'm_name': 'TestCase',
            'disks': ['disc01.zip', 'disc02.zip']
        }
        roms = {rom_id: rom}
        json_data = json.dumps(roms,
                               ensure_ascii=False,
                               indent=1,
                               separators=(',', ':'))

        rom_dir = FakeFile(self.TEST_ASSETS_DIR)
        rom_dir.setFakeContent(json_data)

        mock = FakeExecutor()
        mock_exeFactory.create.return_value = mock

        paths = Fake_Paths('\\fake\\')
        paths.ROMS_DIR = rom_dir

        repository = ROMSetRepository(paths, settings)
        launcher = StandardRomLauncher(paths, settings, launcher_data, None,
                                       mock_exeFactory, repository, None)

        # act
        launcher.select_ROM(rom_id)

        # assert
        actual = launcher.__class__.__name__
        expected = 'StandardRomLauncher'
        self.assertEqual(actual, expected)
Пример #6
0
    def test_when_using_rom_the_factory_will_get_the_correct_launcher(
            self, mock_exeFactory):

        # arrange
        settings = self._get_test_settings()

        launcher_data = {}
        launcher_data['id'] = 'ABC'
        launcher_data['application'] = 'path'
        launcher_data['type'] = OBJ_LAUNCHER_ROM
        launcher_data['toggle_window'] = True
        launcher_data['romext'] = ''
        launcher_data['application'] = ''
        launcher_data['args'] = ''
        launcher_data['args_extra'] = ''
        launcher_data['roms_base_noext'] = 'snes'

        rom_id = 'fghj'
        rom = {'id': rom_id, 'm_name': 'TestCase'}
        roms = {rom_id: rom}
        json_data = json.dumps(roms,
                               ensure_ascii=False,
                               indent=1,
                               separators=(',', ':'))

        rom_dir = FakeFile(self.TEST_ASSETS_DIR)
        rom_dir.setFakeContent(json_data)

        paths = Fake_Paths('\\fake\\')
        paths.ROMS_DIR = NewFileName(self.TEST_ASSETS_DIR)
        repository = ROMSetRepository(paths, settings)

        # act
        launcher = StandardRomLauncher(paths, settings, launcher_data, None,
                                       mock_exeFactory, repository, None)
        launcher.select_ROM(rom_id)

        # assert
        actual = launcher.__class__.__name__
        expected = 'StandardRomLauncher'
        self.assertEqual(actual, expected)