def test_creating_new_archive_after_set_managed_ids_uses_new_ids(self): archive = ManagedROMArchive(self.temppath) new_ids = ["1234567890"] self.assertNotEqual(archive.previous_managed_ids(self.mock_user), new_ids) archive.set_managed_ids(self.mock_user, ["1234567890"]) new_archive = ManagedROMArchive(self.temppath) self.assertEqual(new_archive.previous_managed_ids(self.mock_user), new_ids)
def __init__(self, config_override=None, consoles_override=None, emulators_override=None): self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger() self.logger.debug("Initializing Ice") config_data_path = _path_with_override(config_override, "config.txt") consoles_data_path = _path_with_override(consoles_override, "consoles.txt") emulators_data_path = _path_with_override(emulators_override, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer( managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger)
def test_previous_managed_ids_returns_empty_list_for_missing_user(self): data = {"1337": []} with open(self.temppath, "w+") as f: f.write(json.dumps(data)) archive = ManagedROMArchive(self.temppath) self.assertEquals(archive.previous_managed_ids(self.mock_user), [])
def test_previous_managed_ids_returns_new_value_after_set_managed_ids( self): archive = ManagedROMArchive(self.temppath) new_ids = ["1234567890"] self.assertNotEqual(archive.previous_managed_ids(self.mock_user), new_ids) archive.set_managed_ids(self.mock_user, ["1234567890"]) self.assertEqual(archive.previous_managed_ids(self.mock_user), new_ids)
def test_previous_managed_ids_returns_list_from_json(self): data = { "1234": [ "1234567890", "0987654321", ] } with open(self.temppath, "w+") as f: f.write(json.dumps(data)) archive = ManagedROMArchive(self.temppath) self.assertEquals(archive.previous_managed_ids(self.mock_user), ["1234567890", "0987654321"])
def __init__(self, steam, filesystem, options): """Valid options for creating an IceEngine are as follows: * config - The path to the config file to use. Searches the default paths for 'config.txt' otherwise * consoles - The path to the consoles file to use. Searches the default paths for 'consoles.txt' if none is provided * emulators - The path to the emulators file to use. Searches the default paths for 'emulators.txt' if none is provided """ self.validated_base_environment = False self.validated_configuration = False self.filesystem = filesystem logger.debug("Initializing Ice") config_data_path = _path_with_override(filesystem, options.config, "config.txt") consoles_data_path = _path_with_override(filesystem, options.consoles, "consoles.txt") emulators_data_path = _path_with_override(filesystem, options.emulators, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), filesystem, ) self.steam = steam parser = ROMParser() self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = paths.highest_precedent_data_file( filesystem, "archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer( managed_rom_archive) provider = CombinedProvider( LocalProvider(), ConsoleGridProvider(), ) self.grid_updater = SteamGridUpdater(provider)
def __init__(self, options): """Valid options for creating an IceEngine are as follows: * config - The path to the config file to use. Searches the default paths for 'config.txt' otherwise * consoles - The path to the consoles file to use. Searches the default paths for 'consoles.txt' if none is provided * emulators - The path to the emulators file to use. Searches the default paths for 'emulators.txt' if none is provided * verbose - Turn on debug logging. """ self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger(verbose=options.verbose) self.logger.debug("Initializing Ice") config_data_path = _path_with_override(options.config, "config.txt") consoles_data_path = _path_with_override(options.consoles, "consoles.txt") emulators_data_path = _path_with_override(options.emulators, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer( managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger)
def test_set_managed_ids_creates_new_file_if_needed(self): self.assertFalse(os.path.exists(self.temppath)) archive = ManagedROMArchive(self.temppath) archive.set_managed_ids(self.mock_user, ["1234567890"]) self.assertTrue(os.path.exists(self.temppath))
def test_previous_managed_ids_raises_exception_for_malformed_json(self): with open(self.temppath, "w+") as f: f.write("notrealjson") with self.assertRaises(ValueError): archive = ManagedROMArchive(self.temppath)
def test_previous_managed_ids_returns_empty_list_for_missing_file(self): missing_path = os.path.join("some", "stupid", "path") self.assertFalse(os.path.exists(missing_path)) archive = ManagedROMArchive(missing_path) self.assertEquals(archive.previous_managed_ids(self.mock_user), [])