2
sys.path.insert(0, "../src")
4
import dup_time, file_naming, log
8
class FileNamingTest(unittest.TestCase):
11
"""Check get/parse cycle"""
12
dup_time.setprevtime(10)
13
dup_time.setcurtime(20)
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
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"
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
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
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
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")
50
assert pr.type == "new-sig"
51
assert pr.end_time == 1029826800L
54
if __name__ == "__main__": unittest.main()