def test_write_shortcuts_creates_file_if_it_doesnt_exist(self): d = tempfile.mkdtemp() path = os.path.join(d, "shortcuts.vdf") updated_shortcuts = [_dummy_shortcut()] self.assertFalse(os.path.exists(path)) shortcuts.write_shortcuts(path, updated_shortcuts) self.assertTrue(os.path.exists(path)) self.assertEqual(shortcuts.read_shortcuts(path), updated_shortcuts) os.remove(path) os.rmdir(d)
def test_create_backup_of_shortcuts_creates_copy_of_shortcuts_at_backup_path(self): tempdir = tempfile.mkdtemp() backup_dir = os.path.join(tempdir, "Backups") config = mock() config.backup_directory = backup_dir user = self.user_fixture.get_context() shortcut = model.Shortcut('Plex', '/Path/to/plex', '/Path/to', '', []) user_shortcuts = [shortcut] shortcuts.set_shortcuts(user, user_shortcuts) backups.create_backup_of_shortcuts(config, user) expected_path = backups.shortcuts_backup_path(backup_dir, user) self.assertTrue(os.path.exists(expected_path)) self.assertEqual(shortcuts.read_shortcuts(expected_path), user_shortcuts) shutil.rmtree(tempdir)