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

« back to all changes in this revision

Viewing changes to testing/manifesttest.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, types
 
2
sys.path.insert(0, "../src")
 
3
import manifest, globals, path
 
4
 
 
5
class VolumeInfoTest(unittest.TestCase):
 
6
        """Test VolumeInfo"""
 
7
        def test_basic(self):
 
8
                """Basic VolumeInfoTest"""
 
9
                vi = manifest.VolumeInfo()
 
10
                vi.set_info(3, ("hello", "there"), ())
 
11
                vi.set_hash("MD5", "aoseutaohe")
 
12
                s = vi.to_string()
 
13
                assert type(s) is types.StringType
 
14
                #print "---------\n%s\n---------" % s
 
15
                vi2 = manifest.VolumeInfo()
 
16
                vi2.from_string(s)
 
17
                assert vi == vi2
 
18
 
 
19
        def test_special(self):
 
20
                """Test VolumeInfo with special characters"""
 
21
                vi = manifest.VolumeInfo()
 
22
                vi.set_info(3234, ("\n eu \x233", "heuo", '\xd8\xab\xb1Wb\xae\xc5]\x8a\xbb\x15v*\xf4\x0f!\xf9>\xe2Y\x86\xbb\xab\xdbp\xb0\x84\x13k\x1d\xc2\xf1\xf5e\xa5U\x82\x9aUV\xa0\xf4\xdf4\xba\xfdX\x03\x82\x07s\xce\x9e\x8b\xb34\x04\x9f\x17 \xf4\x8f\xa6\xfa\x97\xab\xd8\xac\xda\x85\xdcKvC\xfa#\x94\x92\x9e\xc9\xb7\xc3_\x0f\x84g\x9aB\x11<=^\xdbM\x13\x96c\x8b\xa7|*"\\\'^$@#!(){}?+ ~` '), ("\n",))
 
23
                s = vi.to_string()
 
24
                assert type(s) is types.StringType
 
25
                #print "---------\n%s\n---------" % s
 
26
                vi2 = manifest.VolumeInfo()
 
27
                vi2.from_string(s)
 
28
                assert vi == vi2
 
29
 
 
30
        def test_contains(self):
 
31
                """Test to see if contains() works"""
 
32
                vi = manifest.VolumeInfo()
 
33
                vi.set_info(1, ("1", "2"), ("1", "3"))
 
34
                assert vi.contains(("1",), recursive = 1)
 
35
                assert not vi.contains(("1",), recursive = 0)
 
36
 
 
37
                vi2 = manifest.VolumeInfo()
 
38
                vi2.set_info(1, ("A",), ("Z",))
 
39
                assert vi2.contains(("M",), recursive = 1)
 
40
                assert vi2.contains(("M",), recursive = 0)
 
41
 
 
42
                vi3 = manifest.VolumeInfo()
 
43
                vi3.set_info(1, ("A",), ("Z",))
 
44
                assert not vi3.contains(("3",), recursive = 1)
 
45
                assert not vi3.contains(("3",), recursive = 0)
 
46
                
 
47
 
 
48
class ManifestTest(unittest.TestCase):
 
49
        """Test Manifest class"""
 
50
        def test_basic(self):
 
51
                vi1 = manifest.VolumeInfo()
 
52
                vi1.set_info(3, ("hello",), ())
 
53
                vi2 = manifest.VolumeInfo()
 
54
                vi2.set_info(4, ("goodbye", "there"), ("aoeusht",))
 
55
                vi3 = manifest.VolumeInfo()
 
56
                vi3.set_info(34, (), ())
 
57
                m = manifest.Manifest()
 
58
                for vi in [vi1, vi2, vi3]: m.add_volume_info(vi)
 
59
 
 
60
                globals.local_path = path.Path("Foobar")
 
61
                m.set_dirinfo()
 
62
 
 
63
                s = m.to_string()
 
64
                #print "---------\n%s\n---------" % s
 
65
                assert s.lower().startswith("hostname")
 
66
                assert s.endswith("\n")
 
67
 
 
68
                m2 = manifest.Manifest().from_string(s)
 
69
                assert m == m2
 
70
 
 
71
 
 
72
if __name__ == "__main__": unittest.main()