~mterry/duplicity/backend-unification

« back to all changes in this revision

Viewing changes to testing/unit/test_collections.py

  • Committer: Michael Terry
  • Date: 2014-04-20 05:58:47 UTC
  • mto: This revision was merged to the branch mainline in revision 978.
  • Revision ID: michael.terry@canonical.com-20140420055847-5btxtxythvsblgpk
More reorg of testing/

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# along with duplicity; if not, write to the Free Software Foundation,
20
20
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
21
 
22
 
import helper
23
22
import os, sys, random, unittest
24
23
 
25
24
from duplicity import collections
26
25
from duplicity import backend
 
26
from duplicity import globals
27
27
from duplicity import path
28
28
from duplicity import gpg
29
 
from duplicity import globals
30
29
from duplicity import dup_time
31
 
 
32
 
helper.setup()
 
30
from . import UnitTestCase
33
31
 
34
32
filename_list1 = ["duplicity-full.2002-08-17T16:17:01-07:00.manifest.gpg",
35
33
                  "duplicity-full.2002-08-17T16:17:01-07:00.vol1.difftar.gpg",
71
69
                  "Extra stuff to be ignored"]
72
70
 
73
71
 
74
 
class CollectionTest(unittest.TestCase):
 
72
class CollectionTest(UnitTestCase):
75
73
    """Test collections"""
76
74
    def setUp(self):
77
 
        assert not os.system("tar xzf testfiles.tar.gz > /dev/null 2>&1")
78
 
        assert not os.system("mkdir testfiles/output")
 
75
        super(CollectionTest, self).setUp()
 
76
 
 
77
        self.unpack_testfiles()
79
78
 
80
79
        col_test_dir = path.Path("testfiles/collectionstest")
81
80
        archive_dir = col_test_dir.append("archive_dir")
82
 
        globals.archive_dir = archive_dir
 
81
        self.set_global('archive_dir', archive_dir)
83
82
        self.archive_dir_backend = backend.get_backend("file://testfiles/collectionstest"
84
83
                                                       "/archive_dir")
85
84
 
88
87
        self.output_dir = path.Path("testfiles/output") # used as a temp directory
89
88
        self.output_dir_backend = backend.get_backend("file://testfiles/output")
90
89
 
91
 
    def tearDown(self):
92
 
        assert not os.system("rm -rf testfiles tempdir temp2.tar")
93
 
 
94
 
    def del_tmp(self):
95
 
        """Reset the testfiles/output directory"""
96
 
        self.output_dir.deltree()
97
 
        self.output_dir.mkdir()
98
 
 
99
90
    def set_gpg_profile(self):
100
91
        """Set gpg profile to standard "foobar" sym"""
101
 
        globals.gpg_profile = gpg.GPGProfile(passphrase = "foobar")
 
92
        self.set_global('gpg_profile', gpg.GPGProfile(passphrase = "foobar"))
102
93
 
103
94
    def test_backup_chains(self):
104
95
        """Test basic backup chain construction"""
193
184
    def get_filelist2_cs(self):
194
185
        """Return set CollectionsStatus object from filelist 2"""
195
186
        # Set up testfiles/output with files from filename_list2
196
 
        self.del_tmp()
197
187
        for filename in filename_list2:
198
188
            p = self.output_dir.append(filename)
199
189
            p.touch()