62
63
self.partials_dir = os.path.join(TESTS_DIR, "partials")
63
64
self.fsm = FileSystemManager(self.fsmdir, self.partials_dir,
64
65
FakeVolumeManager(self.root_dir))
66
self.eq = EventQueue(self.fsm)
67
self.fsm.register_eq(self.eq)
65
68
self.share = self.create_share('share', 'share_name',
66
69
self.fsm, self.shares_dir)
67
70
self.share_path = self.share.path
69
72
def tearDown(self):
70
73
""" Clean up the tests. """
71
75
self.rmtree(TESTS_DIR)
2090
2094
os.chmod(os.path.join(dirpath, dir), 0777)
2091
2095
for file in files:
2092
2096
os.chmod(os.path.join(dirpath, file), 0666)
2093
shutil.rmtree(TESTS_DIR)
2097
FSMTestCase.tearDown(self)
2095
2099
def test_file_ro_share_fail(self):
2096
2100
""" Test that manual creation of a file, fails on a ro-share. """
2241
2245
FSMTestCase.setUp(self)
2242
2246
# create a ro share
2243
2247
self.share_ro = self.create_share('share_ro', 'share_ro_name',
2244
self.fsm, self.shares_dir, access_level='View')
2248
self.fsm, self.shares_dir,
2249
access_level='View')
2245
2250
self.share_ro_path = self.share_ro.path
2247
2252
def test_write_in_ro_share(self):
2248
2253
"""test the EnableShareWrite context manager in a ro share"""
2249
2254
path = os.path.join(self.share_ro_path, 'foo', 'a_file_in_a_ro_share')
2250
2255
data = 'yes I can write!'
2251
can_write_parent = os.access(os.path.dirname(self.share_ro_path), os.W_OK)
2256
can_write_parent = os.access(os.path.dirname(self.share_ro_path),
2252
2258
with EnableShareWrite(self.share_ro, path):
2253
2259
with open(path, 'w') as f:
2255
2261
self.assertEquals(data, open(path, 'r').read())
2256
2262
self.assertFalse(os.access(self.share_ro_path, os.W_OK))
2257
2263
# check that the parent permissions are ok
2258
self.assertEquals(can_write_parent, os.access(os.path.dirname(self.share_ro_path), os.W_OK))
2264
self.assertEquals(can_write_parent,
2265
os.access(os.path.dirname(self.share_ro_path),
2259
2267
# fail to write directly in the share
2260
2268
self.assertRaises(IOError, open, path, 'w')
2291
2299
os.makedirs(self.root_dir)
2292
2300
self.data_dir = os.path.join(TESTS_DIR, "data")
2293
2301
self.partials_dir = os.path.join(TESTS_DIR, "partials")
2294
self.main = FakeMain(self.root_dir, self.shares_dir, self.data_dir, self.partials_dir)
2302
self.main = FakeMain(self.root_dir, self.shares_dir,
2303
self.data_dir, self.partials_dir)
2295
2304
self.fsm = self.main.fs
2296
2305
self.share = self.create_share('share', 'share_name',
2297
2306
self.fsm, self.shares_dir)