406
406
class TestVersionFileStore(TestCaseWithTransport):
409
return self._transaction
409
412
super(TestVersionFileStore, self).setUp()
410
413
self.vfstore = store.versioned.VersionedFileStore(MemoryTransport())
414
self.vfstore.get_scope = self.get_scope
415
self._transaction = None
412
417
def test_get_weave_registers_dirty_in_write(self):
413
transaction = transactions.WriteTransaction()
414
vf = self.vfstore.get_weave_or_empty('id', transaction)
416
self.assertRaises(errors.OutSideTransaction, vf.add_lines, 'b', [], [])
417
transaction = transactions.WriteTransaction()
418
vf = self.vfstore.get_weave('id', transaction)
420
self.assertRaises(errors.OutSideTransaction, vf.add_lines, 'b', [], [])
422
def test_get_weave_or_empty_readonly_fails(self):
423
transaction = transactions.ReadOnlyTransaction()
424
vf = self.assertRaises(errors.ReadOnlyError,
425
self.vfstore.get_weave_or_empty,
418
self._transaction = transactions.WriteTransaction()
419
vf = self.vfstore.get_weave_or_empty('id', self._transaction)
420
self._transaction.finish()
421
self._transaction = None
422
self.assertRaises(errors.OutSideTransaction, vf.add_lines, 'b', [], [])
423
self._transaction = transactions.WriteTransaction()
424
vf = self.vfstore.get_weave('id', self._transaction)
425
self._transaction.finish()
426
self._transaction = None
427
self.assertRaises(errors.OutSideTransaction, vf.add_lines, 'b', [], [])
429
429
def test_get_weave_readonly_cant_write(self):
430
transaction = transactions.WriteTransaction()
431
vf = self.vfstore.get_weave_or_empty('id', transaction)
433
transaction = transactions.ReadOnlyTransaction()
434
vf = self.vfstore.get_weave_or_empty('id', transaction)
430
self._transaction = transactions.WriteTransaction()
431
vf = self.vfstore.get_weave_or_empty('id', self._transaction)
432
self._transaction.finish()
433
self._transaction = transactions.ReadOnlyTransaction()
434
vf = self.vfstore.get_weave_or_empty('id', self._transaction)
435
435
self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'b', [], [])