def test_local_user_contexts_returns_user_context_with_same_steam(self): self._make_folders_in_temp_directory_for_ids(['1234']) s = model.Steam(self.tempdir) contexts = steam.local_user_contexts(s) self.assertEqual(len(contexts), 1) self.assertEqual(contexts[0].steam, s)
def test_local_user_ids_returns_anonymous_user(self): self._make_folders_in_temp_directory_for_ids(['anonymous']) s = model.Steam(self.tempdir) uids = steam.local_user_ids(s) self.assertEqual(len(uids), 1) self.assertEqual(uids[0], 'anonymous')
def test_local_user_ids_returns_list_of_users_with_entries_in_userdata_folder( self): self._make_folders_in_temp_directory_for_ids(['1234', '4567']) s = model.Steam(self.tempdir) uids = steam.local_user_ids(s) self.assertEqual(len(uids), 2) self.assertIn('1234', uids) self.assertIn('4567', uids)
def test_get_and_set_shortcuts_creates_file_at_correct_path(self): tempdir = tempfile.mkdtemp() steam = model.Steam(tempdir) context = model.LocalUserContext(steam=steam, user_id='anonymous') # Create the `anonymous` directory, cause we can't open shortcuts.vdf for # writing if the containing directory doesn't exist os.makedirs(paths.user_config_directory(context)) self.assertFalse(os.path.exists(paths.shortcuts_path(context))) self.assertEqual([], shortcuts.get_shortcuts(context)) updated_shortcuts = [_dummy_shortcut()] shortcuts.set_shortcuts(context, updated_shortcuts) self.assertEqual(updated_shortcuts, shortcuts.get_shortcuts(context)) shutil.rmtree(tempdir)
def get_steam(self): assert (self.tempdir is not None, "Should not have been cleaned up") return steam_model.Steam(self.tempdir)
def test_local_user_ids_returns_empty_list_for_empty_userdata_directory( self): s = model.Steam(self.tempdir) self.assertEqual(len(steam.local_user_ids(s)), 0)
def setUp(self): self.tempdir = tempfile.mkdtemp() s = model.Steam(self.tempdir) self.context = model.LocalUserContext(s, '1234') os.makedirs(paths.custom_images_directory(self.context))