#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# For copyright information, see AUTHORS.
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.

import sys
import os
import subprocess
sys.path.insert(0, sys.path[0]+'/..')
import base
import ldtp

BASEPATH = '/tmp/deja-dup-test/'

def test():
  restoredir = base.get_temp_name('restore')
  files = [BASEPATH+'one', BASEPATH+'top/one']
  base.setup()
  DATE = subprocess.Popen(['date', '-d', '08/01/09 21:14:34', '+%x %X'], stdout=subprocess.PIPE).communicate()[0].strip()
  os.system('rm -rf %s' % BASEPATH)
  base.restore_specific(files, restoredir, DATE, backend='file', dest=(sys.path[0]+'/vols/simple'), encrypt=None)
  assert base.file_equals(BASEPATH+'one', 'one1\n')
  assert base.file_equals(BASEPATH+'top/one', 'one\n')

base.run(test)
