equal
deleted
inserted
replaced
19 Test the CPF root file parsing routines |
19 Test the CPF root file parsing routines |
20 """ |
20 """ |
21 |
21 |
22 import zipfile |
22 import zipfile |
23 import unittest |
23 import unittest |
24 import string |
24 import os,shutil |
25 import sys,os,shutil |
|
26 |
25 |
27 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
26 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
28 |
27 |
29 import __init__ |
28 from cone.public import exceptions |
30 from cone.public.exceptions import * |
|
31 from cone.public.api import Resource |
|
32 from cone.storage import zipstorage |
29 from cone.storage import zipstorage |
33 |
30 |
34 TEMP_DIR = os.path.join(ROOT_PATH, 'temp') |
31 TEMP_DIR = os.path.join(ROOT_PATH, 'temp') |
35 tempzip = os.path.join(ROOT_PATH,"zipres_test.zip") |
32 tempzip = os.path.join(ROOT_PATH,"zipres_test.zip") |
36 |
33 |
97 def test_get_size_fails_in_write_mode(self): |
94 def test_get_size_fails_in_write_mode(self): |
98 ZIPFILE = os.path.join(TEMP_DIR, 'getsize_fails_in_write_mode.zip') |
95 ZIPFILE = os.path.join(TEMP_DIR, 'getsize_fails_in_write_mode.zip') |
99 store = zipstorage.ZipStorage(ZIPFILE, "w") |
96 store = zipstorage.ZipStorage(ZIPFILE, "w") |
100 res = store.open_resource("test_getsize.txt", "w") |
97 res = store.open_resource("test_getsize.txt", "w") |
101 res.write("Writing foobar") |
98 res.write("Writing foobar") |
102 self.assertRaises(StorageException, res.get_size) |
99 self.assertRaises(exceptions.StorageException, res.get_size) |
103 res.close() |
100 res.close() |
104 store.close() |
101 store.close() |
105 |
102 |
106 def test_get_content_info_and_read_data(self): |
103 def test_get_content_info_and_read_data(self): |
107 ZIPFILE = self._prepare_tempzip('test2.zip') |
104 ZIPFILE = self._prepare_tempzip('test2.zip') |
114 res.close() |
111 res.close() |
115 store.close() |
112 store.close() |
116 |
113 |
117 |
114 |
118 if __name__ == '__main__': |
115 if __name__ == '__main__': |
119 unittest.main() |
116 unittest.main() |