~ed.so/duplicity/reuse-passphrase-for-signing-fix

« back to all changes in this revision

Viewing changes to testing/rdiffdirtest.py

  • Committer: bescoto
  • Date: 2002-10-29 01:49:46 UTC
  • Revision ID: vcs-imports@canonical.com-20021029014946-3m4rmm5plom7pl6q
Initial checkin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys, unittest, os
 
2
sys.path.insert(0, "../src")
 
3
import path
 
4
 
 
5
class RdiffdirTest(unittest.TestCase):
 
6
        """Test rdiffdir command line program"""
 
7
        def run(self, command): assert not os.system(command)
 
8
        def del_tmp(self):
 
9
                """Make new testfiles/output dir"""
 
10
                self.run("rm -rf testfiles/output")
 
11
                os.mkdir("testfiles/output")
 
12
 
 
13
        def run_rdiffdir(self, argstring):
 
14
                """Run rdiffdir with given arguments"""
 
15
                self.run("../rdiffdir " + argstring)
 
16
 
 
17
        def run_cycle(self, dirname_list):
 
18
                """Run diff/patch cycle on directories in dirname_list"""
 
19
                assert len(dirname_list) >= 2
 
20
                self.del_tmp()
 
21
 
 
22
                seq_path = path.Path("testfiles/output/sequence")
 
23
                new_path = path.Path(dirname_list[0])
 
24
                delta_path = path.Path("testfiles/output/delta.tar")
 
25
                sig_path = path.Path("testfiles/output/sig.tar")
 
26
 
 
27
                self.run("cp -a %s %s" % (new_path.name, seq_path.name))
 
28
                seq_path.setdata()
 
29
                self.run_rdiffdir("sig %s %s" % (seq_path.name, sig_path.name))
 
30
                sig_path.setdata()
 
31
                assert sig_path.exists()
 
32
                assert new_path.compare_recursive(seq_path, verbose = 1)
 
33
 
 
34
                for dirname in dirname_list[1:]:
 
35
                        new_path = path.Path(dirname)
 
36
 
 
37
                        # Make delta
 
38
                        if delta_path.exists(): delta_path.delete()
 
39
                        assert not delta_path.exists()
 
40
                        self.run_rdiffdir("delta %s %s %s" %
 
41
                                                          (sig_path.name, new_path.name, delta_path.name))
 
42
                        delta_path.setdata()
 
43
                        assert delta_path.exists()
 
44
 
 
45
                        # patch and compare
 
46
                        self.run_rdiffdir("patch %s %s" % (seq_path.name, delta_path.name))
 
47
                        seq_path.setdata()
 
48
                        new_path.setdata()
 
49
                        assert new_path.compare_recursive(seq_path, verbose = 1)
 
50
 
 
51
                        # Make new signature
 
52
                        sig_path.delete()
 
53
                        assert not sig_path.exists()
 
54
                        self.run_rdiffdir("sig %s %s" % (seq_path.name, sig_path.name))
 
55
                        sig_path.setdata()
 
56
                        assert sig_path.isreg()
 
57
 
 
58
        def test_dirx(self):
 
59
                """Test cycle on testfiles/dirx"""
 
60
                self.run_cycle(['testfiles/empty_dir',
 
61
                                                'testfiles/dir1',
 
62
                                                'testfiles/dir2',
 
63
                                                'testfiles/dir3',
 
64
                                                'testfiles/empty_dir'])
 
65
 
 
66
 
 
67
if __name__ == "__main__": unittest.main()