def test_synchronized_zone_exception_raised(self): @service.synchronized_zone() def mock_get_zone(cls, index, zone): self.assertEqual(service.ZONE_LOCKS.held, {zone.id}) if index % 3 == 0: raise exceptions.ZoneNotFound() for index in range(9): try: mock_get_zone(object, index, zone.Zone(id=utils.generate_uuid())) except exceptions.ZoneNotFound: pass
def test_synchronized_zone_recursive_decorator_call(self): @service.synchronized_zone() def mock_create_record(cls, context, record): self.assertEqual(service.ZONE_LOCKS.held, {record.zone_id}) mock_get_zone(cls, context, zone.Zone(id=record.zone_id)) @service.synchronized_zone() def mock_get_zone(cls, context, zone): self.assertEqual(service.ZONE_LOCKS.held, {zone.id}) mock_create_record(object, self.get_context(), record=record.Record(zone_id=utils.generate_uuid())) mock_get_zone(object, self.get_context(), zone=zone.Zone(id=utils.generate_uuid()))
def mock_create_record(cls, context, record): self.assertEqual(service.ZONE_LOCKS.held, {record.zone_id}) mock_get_zone(cls, context, zone.Zone(id=record.zone_id))