Пример #1
0
  def test_create_backup_of_shortcuts_does_nothing_if_backups_directory_is_none(self):
    config = mock()
    config.backup_directory = None

    user = self.user_fixture.get_context()

    expected_dir = backups.default_backups_directory()
    expected_location = backups.shortcuts_backup_path(expected_dir, user)

    self.assertFalse(os.path.exists(expected_location))
    backups.create_backup_of_shortcuts(config, user)
    self.assertFalse(os.path.exists(expected_location))
Пример #2
0
  def test_create_backup_of_shortcuts_does_nothing_if_backups_directory_is_none(self):
    config = mock()
    config.backup_directory = None

    user = self.user_fixture.get_context()

    expected_dir = backups.default_backups_directory()
    expected_location = backups.shortcuts_backup_path(expected_dir, user)

    self.assertFalse(os.path.exists(expected_location))
    backups.create_backup_of_shortcuts(config, user)
    self.assertFalse(os.path.exists(expected_location))
Пример #3
0
  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', '', '', '', False, False, False, 0, [])
    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)
Пример #4
0
  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)