class TestLimitSizeFS(TestWrapFS): _dont_retest = TestWrapFS._dont_retest + ("test_big_file",) def setUp(self): super(TestLimitSizeFS,self).setUp() self.fs = LimitSizeFS(self.fs,1024*1024*2) # 2MB limit def tearDown(self): remove_all(self.fs, "/") self.assertEquals(self.fs.cur_size,0) super(TestLimitSizeFS,self).tearDown() self.fs.close() def test_storage_error(self): total_written = 0 for i in xrange(1024*2): try: total_written += 1030 self.fs.setcontents("file %i" % i, b("C")*1030) except StorageSpaceError: self.assertTrue(total_written > 1024*1024*2) self.assertTrue(total_written < 1024*1024*2 + 1030) break else: self.assertTrue(False,"StorageSpaceError not raised")
def setUp(self): multifs = WritableMultiFS() fs1 = LimitSizeFS(MemoryFS(), mb(230)) fs2 = LimitSizeFS(MemoryFS(), mb(300)) multifs.addfs("fs1", fs1) multifs.addfs("fs2", fs2) self.fs = multifs
def fs(self): multifs = WritableMultiFS() fs1 = LimitSizeFS(MemoryFS(), mb(300)) fs2 = LimitSizeFS(MemoryFS(), mb(240)) multifs.addfs("fs1", fs1) multifs.addfs("fs2", fs2) return multifs
def test_free_space_returns_cur_size_if_is_limitsizefs(self): # Arrange fs = LimitSizeFS(MemoryFS(), mb(230)) # Act space = free_space(fs) # Assert assert space == mb(230)
def setUp(self): super(TestLimitSizeFS,self).setUp() self.fs = LimitSizeFS(self.fs,1024*1024*2) # 2MB limit
def filesystems(self): userfs = TempFS() fs1 = LimitSizeFS(MemoryFS(), mb(300)) fs2 = LimitSizeFS(MemoryFS(), mb(300)) remotefs = CuckooDriveFS(remote_filesystems=[fs1, fs2]) return (userfs, remotefs)
def fs(self, request): fs1 = LimitSizeFS(MemoryFS(), mb(300)) fs2 = LimitSizeFS(MemoryFS(), mb(300)) fs = CuckooDriveFS([fs1, fs2]) request.addfinalizer(lambda: fs.close()) return fs
def setUp(self): fs1 = LimitSizeFS(MemoryFS(), mb(300)) fs2 = LimitSizeFS(MemoryFS(), mb(300)) self.fs = CuckooDriveFS([fs1, fs2])