1 | import sys |
---|
2 | |
---|
3 | base = "/Users/kacarstensen/Documents/code/tahoe/support/lib/python2.6/site-packages" |
---|
4 | sys.path.append(base) |
---|
5 | |
---|
6 | from base64 import b32encode |
---|
7 | from test.test_dirnode import FakeClient |
---|
8 | |
---|
9 | class TestProgram: |
---|
10 | def __init__(self): |
---|
11 | self.client = FakeClient() |
---|
12 | |
---|
13 | def create_directory_tree(self): |
---|
14 | d = self.client.create_empty_dirnode() |
---|
15 | |
---|
16 | def _create_files(rootdir): |
---|
17 | # Create a small directory tree |
---|
18 | # root/ |
---|
19 | # root/file1 |
---|
20 | # root/file2 |
---|
21 | # root/file3 |
---|
22 | self.rootdir = rootdir |
---|
23 | d = rootdir.add_file(u"file1", upload.Data(u'file1', None)) |
---|
24 | d.addCallback(lambda res: |
---|
25 | rootdir.add_file(u'file2', upload.Data("bbbb", None))) |
---|
26 | d.addCallback(lambda res: |
---|
27 | rootdir.add_file(u'file3', upload.Data("bbbbc", None))) |
---|
28 | return d |
---|
29 | |
---|
30 | d.addCallback(_create_files) |
---|
31 | return d |
---|
32 | |
---|
33 | def get_string(self): |
---|
34 | children = self.rootdir._read() |
---|
35 | def _print_contents(contents): |
---|
36 | packed_contents = self.rootdir._pack_contents(contents) |
---|
37 | print packed_contents |
---|
38 | |
---|
39 | children.addCallback(_print_contents) |
---|
40 | return children |
---|
41 | |
---|
42 | def run(self): |
---|
43 | self.create_directory_tree() |
---|
44 | self.get_string() |
---|
45 | |
---|
46 | p = TestProgram() |
---|
47 | p.run() |
---|