1 #!/usr/bin/env python2.3
2 import sys
, tempfile
, os
, shutil
4 from logging
import getLogger
, DEBUG
, INFO
5 #getLogger().setLevel(DEBUG)
7 sys
.path
.insert(0, '..')
9 from zeroinstall
.zerostore
import Store
, manifest
11 class TestStore(unittest
.TestCase
):
13 path
= tempfile
.mktemp()
15 self
.store
= Store(path
)
17 self
.tmp
= tempfile
.mktemp()
21 shutil
.rmtree(self
.store
.dir)
22 shutil
.rmtree(self
.tmp
)
25 assert os
.path
.isdir(self
.store
.dir)
26 self
.assertEquals([], os
.listdir(self
.store
.dir))
28 def testEmptyManifest(self
):
29 lines
= list(manifest
.generate_manifest(self
.tmp
))
30 self
.assertEquals([], lines
)
32 def testSimpleManifest(self
):
33 path
= os
.path
.join(self
.tmp
, 'MyFile')
37 os
.utime(path
, (1, 2))
38 lines
= list(manifest
.generate_manifest(self
.tmp
))
39 self
.assertEquals(['F f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 2 5 MyFile'],
42 def testLinkManifest(self
):
43 path
= os
.path
.join(self
.tmp
, 'MyLink')
44 os
.symlink('Hello', path
)
45 lines
= list(manifest
.generate_manifest(self
.tmp
))
46 self
.assertEquals(['S f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 5 MyLink'],
49 suite
= unittest
.makeSuite(TestStore
)
50 if __name__
== '__main__':