def make_istatepersister_tests(fixture):
 class IStatePersisterTests(TestCase, ):
  '\n        Tests for ``IStatePersister`` implementations.\n        '
  def test_interface(self):
   '\n            The object implements ``IStatePersister``.\n            '
   (state_persister, _get_state) = fixture(self)
   verifyObject(IStatePersister, state_persister)
  @given(dataset_id=uuids(), blockdevice_id=text())
  def test_records_blockdeviceid(self, dataset_id, blockdevice_id):
   '\n            Calling ``record_ownership`` records the blockdevice\n            mapping in the state.\n            '
   (state_persister, get_state) = fixture(self)
   d = state_persister.record_ownership(dataset_id=dataset_id, blockdevice_id=blockdevice_id)
   self.successResultOf(d)
   self.assertEqual(get_state().blockdevice_ownership[dataset_id], blockdevice_id)
  @given(dataset_id=uuids(), blockdevice_id=text(), other_blockdevice_id=text())
  def test_duplicate_blockdevice_id(self, dataset_id, blockdevice_id, other_blockdevice_id):
   '\n            Calling ``record_ownership`` raises\n            ``DatasetAlreadyOwned`` if the dataset already has a\n            associated blockdevice.\n            '
   assume((blockdevice_id != other_blockdevice_id))
   (state_persister, get_state) = fixture(self)
   self.successResultOf(state_persister.record_ownership(dataset_id=dataset_id, blockdevice_id=blockdevice_id))
   self.failureResultOf(state_persister.record_ownership(dataset_id=dataset_id, blockdevice_id=other_blockdevice_id), DatasetAlreadyOwned)
   self.assertEqual(get_state().blockdevice_ownership[dataset_id], blockdevice_id)
 return IStatePersisterTests

def make_istatepersister_tests ( fixture ) : class IStatePersisterTests ( TestCase , ) : def test_interface ( self ) : ( state_persister , _get_state ) = fixture ( self ) verifyObject ( IStatePersister , state_persister ) @ given ( dataset_id = uuids ( ) , blockdevice_id = text ( ) ) def test_records_blockdeviceid ( self , dataset_id , blockdevice_id ) : ( state_persister , get_state ) = fixture ( self ) d = state_persister . record_ownership ( dataset_id = dataset_id , blockdevice_id = blockdevice_id ) self . successResultOf ( d ) self . assertEqual ( get_state ( ) . blockdevice_ownership [ dataset_id ] , blockdevice_id ) @ given ( dataset_id = uuids ( ) , blockdevice_id = text ( ) , other_blockdevice_id = text ( ) ) def test_duplicate_blockdevice_id ( self , dataset_id , blockdevice_id , other_blockdevice_id ) : assume ( ( blockdevice_id != other_blockdevice_id ) ) ( state_persister , get_state ) = fixture ( self ) self . successResultOf ( state_persister . record_ownership ( dataset_id = dataset_id , blockdevice_id = blockdevice_id ) ) self . failureResultOf ( state_persister . record_ownership ( dataset_id = dataset_id , blockdevice_id = other_blockdevice_id ) , DatasetAlreadyOwned ) self . assertEqual ( get_state ( ) . blockdevice_ownership [ dataset_id ] , blockdevice_id ) return IStatePersisterTests
create a testcase for istatepersister .