Esempio n. 1
0
 def test_removed_shortcuts_doesnt_return_shortcuts_that_still_exist(self):
     shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     old = [shortcut1, shortcut2]
     new = [shortcut1, shortcut2]
     self.assertEquals(self.synchronizer.removed_shortcuts(old, new), [])
Esempio n. 2
0
 def test_added_shortcuts_returns_shortcuts_that_didnt_exist_previously(
         self):
     shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     new = [shortcut1, shortcut2]
     self.assertEquals(self.synchronizer.added_shortcuts([], new),
                       [shortcut1, shortcut2])
Esempio n. 3
0
 def test_unmanaged_shortcuts_doesnt_return_shortcut_with_appid_in_managed_ids(
         self):
     managed_shortcut = steam_model.Shortcut("Game", "/Path/to/game",
                                             "/Path/to", "", "", "", False,
                                             False, False, 0, [])
     random_shortcut = steam_model.Shortcut("Plex",
                                            "/Some/Random/Path/plex",
                                            "/Some/Random/Path", "", "", "",
                                            False, False, False, 0, [])
     managed_ids = [shortcuts.shortcut_app_id(managed_shortcut)]
     all_shortcuts = [managed_shortcut, random_shortcut]
     unmanaged = self.synchronizer.unmanaged_shortcuts(
         managed_ids, all_shortcuts, None)
     self.assertEquals(unmanaged, [random_shortcut])
Esempio n. 4
0
    def test_sync_roms_for_user_logs_once_for_each_removed_rom(self):
        shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to",
                                         "", "", "", False, False, False, 0,
                                         [roms.ICE_FLAG_TAG])
        shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to",
                                         "", "", "", False, False, False, 0,
                                         [roms.ICE_FLAG_TAG])
        shortcut3 = steam_model.Shortcut("Game3", "/Path/to/game3", "/Path/to",
                                         "", "", "", False, False, False, 0,
                                         [roms.ICE_FLAG_TAG])
        self._set_users_shortcuts([shortcut1, shortcut2, shortcut3])

        self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(),
                                             [], None)
        verify(self.mock_logger, times=3).info(any())
Esempio n. 5
0
 def test_unmanaged_shortcuts_doesnt_return_shortcut_with_flag_tag(self):
     tagged_shortcut = steam_model.Shortcut("Game", "/Path/to/game",
                                            "/Path/to", "", "", "", False,
                                            False, False, 0,
                                            [roms.ICE_FLAG_TAG])
     unmanaged = self.synchronizer.unmanaged_shortcuts([],
                                                       [tagged_shortcut],
                                                       None)
     self.assertEquals(unmanaged, [])
Esempio n. 6
0
    def test_sync_roms_for_user_logs_when_a_rom_is_removed(self):
        shortcut = steam_model.Shortcut("Game", "/Path/to/game", "/Path/to",
                                        "", "", "", False, False, False, 0,
                                        [roms.ICE_FLAG_TAG])
        self._set_users_shortcuts([shortcut])

        self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(),
                                             [], None)
        verify(self.mock_logger).info(any())
Esempio n. 7
0
 def test_removed_shortcuts_only_returns_shortcuts_that_dont_exist_now_but_did_before(
         self):
     shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     shortcut3 = steam_model.Shortcut("Game3", "/Path/to/game3", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     shortcut4 = steam_model.Shortcut("Game4", "/Path/to/game4", "/Path/to",
                                      "", "", "", False, False, False, 0,
                                      [roms.ICE_FLAG_TAG])
     old = [shortcut1, shortcut2, shortcut3, shortcut4]
     new = [shortcut1, shortcut2]
     self.assertEquals(self.synchronizer.removed_shortcuts(old, new),
                       [shortcut3, shortcut4])
Esempio n. 8
0
 def test_unmanaged_shortcuts_returns_shortcut_not_affiliated_with_ice(
         self):
     random_shortcut = steam_model.Shortcut("Plex",
                                            "/Some/Random/Path/plex",
                                            "/Some/Random/Path", "", "", "",
                                            False, False, False, 0, [])
     unmanaged = self.synchronizer.unmanaged_shortcuts([],
                                                       [random_shortcut],
                                                       None)
     self.assertEquals(unmanaged, [random_shortcut])
Esempio n. 9
0
    def test_unmanaged_shortcuts_filters_suspicious_shortcuts_when_given_no_history(
            self):
        dummy_console = self._create_dummy_console("/Some/Path")
        random_shortcut = steam_model.Shortcut(
            "Iron Man", "/Some/Emulator/Path/emulator /Some/Path/Iron Man",
            "/Some/Emulator/Path", "", "", "", False, False, False, 0, [])

        unmanaged = self.synchronizer.unmanaged_shortcuts(
            None, [random_shortcut], [dummy_console])

        self.assertEquals(unmanaged, [])
Esempio n. 10
0
    def test_unmanaged_shortcuts_returns_all_shortcuts_when_given_no_history(
            self):
        dummy_console = self._create_dummy_console("/Some/Other/Path")
        random_shortcut = steam_model.Shortcut("Plex",
                                               "/Some/Random/Path/plex",
                                               "/Some/Random/Path", "", "", "",
                                               False, False, False, 0, [])

        unmanaged = self.synchronizer.unmanaged_shortcuts(
            None, [random_shortcut], [dummy_console])

        self.assertEquals(unmanaged, [random_shortcut])
Esempio n. 11
0
class ROMsTests(unittest.TestCase):
    def setUp(self):
        pass

    @parameterized.expand([
        (None, paths.default_roms_directory()),
        ("", paths.default_roms_directory()),
        ('/roms/', '/roms/'),
    ])
    def test_roms_directory(self, config_directory, expected):
        config = mock()
        config.roms_directory = config_directory
        self.assertEqual(roms.roms_directory(config), expected)

    @parameterized.expand([
        ('Banjo Kazoomie', None, 'Banjo Kazoomie'),
        ('Banjo Kazoomie', '[Vapor]', '[Vapor] Banjo Kazoomie'),
        ('Game Name', '!Something!', '!Something! Game Name'),
    ])
    def test_rom_shortcut_name(self, name, console_prefix, expected):
        console = model.Console(
            fullname='Nintendo Entertainment System',
            shortname='NES',
            extensions='',
            custom_roms_directory='',
            prefix=console_prefix,
            icon='',
            images_directory='',
            emulator=None,
        )
        rom = model.ROM(name=name, path='/Path/to/ROM', console=console)
        self.assertEqual(roms.rom_shortcut_name(rom), expected)

    @parameterized.expand([
        (fixtures.roms.banjo_kazooie,
         steam_model.Shortcut(name='[NES] Banjo Kazooie',
                              exe='\"/emulators/Mednafen/mednafen\"',
                              startdir='/emulators/Mednafen',
                              icon='/consoles/icons/nes.png',
                              shortcut_path='',
                              launch_options='\"/roms/nes/Banjo Kazooie.nes\"',
                              hidden=False,
                              allow_desktop_config=False,
                              open_vr=False,
                              last_play_time=0,
                              tags=['Nintendo Entertainment System']))
    ])
    def test_rom_to_shortcut(self, rom, expected):
        self.assertEqual(roms.rom_to_shortcut(rom), expected)
Esempio n. 12
0
def rom_to_shortcut(rom):
    emu = rom.console.emulator
    assert (emu is not None)

    return steam_model.Shortcut(
        name=rom_shortcut_name(rom),
        exe=emulators.emulator_rom_exe(emu),
        startdir=emulators.emulator_startdir(emu),
        icon=rom.console.icon,
        shortcut_path="",
        launch_options=emulators.emulator_rom_launch_options(emu, rom),
        hidden=False,
        allow_desktop_config=False,
        open_vr=False,
        last_play_time=0,
        tags=[rom.console.fullname])
Esempio n. 13
0
    def test_sync_roms_for_user_keeps_unmanaged_shortcuts(self):
        random_shortcut = steam_model.Shortcut("Plex",
                                               "/Some/Random/Path/plex",
                                               "/Some/Random/Path", "", "", "",
                                               False, False, False, 0, [])
        self._set_users_shortcuts([random_shortcut])
        when(self.mock_archive).previous_managed_ids(
            self.user_fixture.get_context()).thenReturn([])

        rom1 = model.ROM(name='Game1',
                         path='/Path/to/game1',
                         console=fixtures.consoles.flagged)
        shortcut1 = roms.rom_to_shortcut(rom1)
        rom2 = model.ROM(name='Game2',
                         path='/Path/to/game2',
                         console=fixtures.consoles.flagged)
        shortcut2 = roms.rom_to_shortcut(rom2)
        rom3 = model.ROM(name='Game3',
                         path='/Path/to/game3',
                         console=fixtures.consoles.flagged)
        shortcut3 = roms.rom_to_shortcut(rom3)
        rom4 = model.ROM(name='Game4',
                         path='/Path/to/game4',
                         console=fixtures.consoles.flagged)
        shortcut4 = roms.rom_to_shortcut(rom4)

        self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(),
                                             [rom1, rom2, rom3, rom4], None)
        new_shortcuts = shortcuts.get_shortcuts(
            self.user_fixture.get_context())

        self.assertEquals(len(new_shortcuts), 5)
        self.assertIn(random_shortcut, new_shortcuts)
        self.assertIn(shortcut1, new_shortcuts)
        self.assertIn(shortcut2, new_shortcuts)
        self.assertIn(shortcut3, new_shortcuts)
        self.assertIn(shortcut4, new_shortcuts)