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

« back to all changes in this revision

Viewing changes to testing/file_namingtest.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
 
2
sys.path.insert(0, "../src")
 
3
import unittest
 
4
import dup_time, file_naming, log
 
5
 
 
6
log.setverbosity(5)
 
7
 
 
8
class FileNamingTest(unittest.TestCase):
 
9
        """Test file naming"""
 
10
        def test_basic(self):
 
11
                """Check get/parse cycle"""
 
12
                dup_time.setprevtime(10)
 
13
                dup_time.setcurtime(20)
 
14
 
 
15
                filename = file_naming.get("inc", volume_number = 23)
 
16
                log.Log("Inc filename: " + filename, 5)
 
17
                pr = file_naming.parse(filename)
 
18
                assert pr and pr.type == "inc", pr
 
19
                assert pr.start_time == 10
 
20
                assert pr.end_time == 20
 
21
                assert pr.volume_number == 23
 
22
 
 
23
                filename = file_naming.get("full-sig")
 
24
                log.Log("Full sig filename: " + filename, 5)
 
25
                pr = file_naming.parse(filename)
 
26
                assert pr.type == "full-sig"
 
27
                assert pr.time == 20
 
28
 
 
29
                pr = file_naming.parse(file_naming.get("new-sig"))
 
30
                assert pr.type == "new-sig"
 
31
                assert pr.start_time == 10
 
32
                assert pr.end_time == 20
 
33
 
 
34
        def test_suffix(self):
 
35
                """Test suffix (encrypt/compressed) encoding and generation"""
 
36
                filename = file_naming.get("inc", manifest = 1, gzipped = 1)
 
37
                pr = file_naming.parse(filename)
 
38
                assert pr and pr.compressed == 1
 
39
                assert pr.manifest
 
40
 
 
41
                filename2 = file_naming.get("full", volume_number = 23, encrypted = 1)
 
42
                pr = file_naming.parse(filename2)
 
43
                assert pr and pr.encrypted == 1
 
44
                assert pr.volume_number == 23
 
45
 
 
46
        def test_more(self):
 
47
                """More file_parsing tests"""
 
48
                pr = file_naming.parse("duplicity-new-signatures.2002-08-18T00:04:30-07:00.to.2002-08-20T00:00:00-07:00.sigtar.gpg")
 
49
                assert pr, pr
 
50
                assert pr.type == "new-sig"
 
51
                assert pr.end_time == 1029826800L
 
52
                
 
53
 
 
54
if __name__ == "__main__": unittest.main()