示例#1
0
 def test_lookup_updating(self):
     record = xlease.Record(make_uuid(), 0, updating=True)
     with make_volume((42, record)) as vol:
         leases = vol.leases()
         self.assertTrue(leases[record.resource]["updating"])
         with self.assertRaises(xlease.LeaseUpdating):
             vol.lookup(record.resource)
示例#2
0
 def test_lookup_stale(self):
     record = xlease.Record(make_uuid(), xlease.RECORD_STALE)
     with make_volume((42, record)) as vol:
         leases = vol.leases()
         self.assertEqual(leases[record.resource]["state"], "STALE")
         with self.assertRaises(xlease.StaleLease):
             vol.lookup(record.resource)
示例#3
0
 def test_lookup_updating(self, tmp_vol):
     record = xlease.Record(make_uuid(), 0, updating=True)
     tmp_vol.write_records((42, record))
     vol = xlease.LeasesVolume(tmp_vol.backend)
     with utils.closing(vol):
         leases = vol.leases()
         assert leases[record.resource]["updating"]
         with pytest.raises(xlease.LeaseUpdating):
             vol.lookup(record.resource)
示例#4
0
 def test_remove_write_failure(self):
     record = xlease.Record(make_uuid(), 0, updating=True)
     with make_volume((42, record)) as base:
         file = FailingWriter(base.path)
         with utils.closing(file):
             vol = xlease.LeasesVolume(file)
             with utils.closing(vol):
                 with self.assertRaises(WriteError):
                     vol.remove(record.resource)
                 # Must succeed becuase writng to storage failed
                 self.assertIn(record.resource, vol.leases())
示例#5
0
 def test_remove_write_failure(self, tmp_vol):
     record = xlease.Record(make_uuid(), 0, updating=True)
     tmp_vol.write_records((42, record))
     backend = FailingWriter(tmp_vol.path)
     with utils.closing(backend):
         vol = xlease.LeasesVolume(backend, block_size=tmp_vol.block_size)
         with utils.closing(vol):
             with pytest.raises(WriteError):
                 vol.remove(record.resource)
             # Must succeed becuase writng to storage failed
             assert record.resource in vol.leases()