1
import sys, unittest, types
2
sys.path.insert(0, "../src")
3
import manifest, globals, path
5
class VolumeInfoTest(unittest.TestCase):
8
"""Basic VolumeInfoTest"""
9
vi = manifest.VolumeInfo()
10
vi.set_info(3, ("hello", "there"), ())
11
vi.set_hash("MD5", "aoseutaohe")
13
assert type(s) is types.StringType
14
#print "---------\n%s\n---------" % s
15
vi2 = manifest.VolumeInfo()
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",))
24
assert type(s) is types.StringType
25
#print "---------\n%s\n---------" % s
26
vi2 = manifest.VolumeInfo()
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)
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)
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)
48
class ManifestTest(unittest.TestCase):
49
"""Test Manifest class"""
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)
60
globals.local_path = path.Path("Foobar")
64
#print "---------\n%s\n---------" % s
65
assert s.lower().startswith("hostname")
66
assert s.endswith("\n")
68
m2 = manifest.Manifest().from_string(s)
72
if __name__ == "__main__": unittest.main()