~ubuntu-branches/ubuntu/saucy/deja-dup/saucy

« back to all changes in this revision

Viewing changes to tests/restore/full

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2012-10-30 19:03:03 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20121030190303-w3fatge63ncm5uiw
Tags: 25.1.1-0ubuntu1
* New upstream release
* debian/control:
  - Use libsecret, not libgnome-keyring
  - Switch to valac-0.18
  - Add various deja-dup-backend-* metapackages to make seeding
    different ones easier for flavors
* debian/tests:
  - Add dep8 test to run upstream test suite against system install
* debian/patches/support-new-u1backend.patch:
  - Support new u1backend in duplicity 0.6.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
3
 
#
4
 
# This file is part of Déjà Dup.
5
 
# For copyright information, see AUTHORS.
6
 
#
7
 
# Déjà Dup is free software; you can redistribute it and/or modify
8
 
# it under the terms of the GNU General Public License as published by
9
 
# the Free Software Foundation; either version 3 of the License, or
10
 
# (at your option) any later version.
11
 
#
12
 
# Déjà Dup is distributed in the hope that it will be useful, but
13
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
# General Public License for more details.
16
 
#
17
 
# You should have received a copy of the GNU General Public License
18
 
# along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
19
 
 
20
 
import sys
21
 
import os
22
 
import subprocess
23
 
import stat
24
 
sys.path.insert(0, sys.path[0]+'/..')
25
 
import base
26
 
import ldtp
27
 
 
28
 
BASEPATH = '/tmp/deja-dup-test/'
29
 
 
30
 
def check_dir(path, oneval):
31
 
  root = path+BASEPATH
32
 
  assert base.file_equals(root+'one', oneval)
33
 
  assert base.file_equals(root+'two', 'two\n')
34
 
  assert base.file_equals(root+'three', 'three\n')
35
 
  assert base.file_equals(root+'top/one', 'one\n')
36
 
  assert os.path.isdir(root+'top/next')
37
 
 
38
 
def test():
39
 
  restoredir = base.get_temp_name('restore', make=True)
40
 
  os.chmod(restoredir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # give new root all permissions
41
 
  os.chmod(base.temp_dir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # and parent of new root
42
 
  before = os.stat(restoredir)
43
 
  beforeparent = os.stat(base.temp_dir)
44
 
  base.setup()
45
 
  DATE1 = subprocess.Popen(['date', '-d', '2009-08-01 21:14:21', '+%x %X'], stdout=subprocess.PIPE).communicate()[0].strip()
46
 
  DATE2 = subprocess.Popen(['date', '-d', '2009-08-01 21:14:34', '+%x %X'], stdout=subprocess.PIPE).communicate()[0].strip()
47
 
  DATE3 = subprocess.Popen(['date', '-d', '2009-08-01 21:14:41', '+%x %X'], stdout=subprocess.PIPE).communicate()[0].strip()
48
 
  base.restore_simple(restoredir, date=DATE1, backend='file', dest=(sys.path[0]+'/vols/simple'), encrypt=None)
49
 
  # A concern is that DD will overwrite the permissions of the restore directory or its parents, so check that here
50
 
  after = os.stat(restoredir)
51
 
  assert before.st_mode == after.st_mode, after.st_mode
52
 
  assert before.st_uid == after.st_uid, after.st_uid
53
 
  assert before.st_gid == after.st_gid, after.st_gid
54
 
  afterparent = os.stat(base.temp_dir)
55
 
  assert beforeparent.st_mode == afterparent.st_mode, afterparent.st_mode
56
 
  assert beforeparent.st_uid == afterparent.st_uid, afterparent.st_uid
57
 
  assert beforeparent.st_gid == afterparent.st_gid, afterparent.st_gid
58
 
  check_dir(restoredir, 'one\n')
59
 
  os.system("rm -r %s" % restoredir)
60
 
  base.restore_simple(restoredir, DATE2, encrypt=None)
61
 
  check_dir(restoredir, 'one1\n')
62
 
  os.system("rm -r %s" % restoredir)
63
 
  base.restore_simple(restoredir, DATE3, encrypt=None)
64
 
  check_dir(restoredir, 'one1!\n')
65
 
 
66
 
base.run(test)