def search(self, regex):
        try:
            spec = {'$or': [{'data.content'    : {'$regex': regex, '$options': 'im'}},
                            {'data.description': {'$regex': regex, '$options': 'im'}}]}
            fields = {'_id': 0}
            cur = self.db.docs.find(spec, fields)
        except Exception as e:
            raise DatabaseException(e)
        return [Document(**row) for row in cur]
def test_reserve_unreserve_volume(self):
        """Test reserving and unreserving volume"""
        # Mark volume as reserved.
        self.volumes_client.reserve_volume(self.volume['id'])
        # To get the volume info
        body = self.volumes_client.show_volume(self.volume['id'])['volume']
        self.assertIn('attaching', body['status'])
        # Unmark volume as reserved.
        self.volumes_client.unreserve_volume(self.volume['id'])
        # To get the volume info
        body = self.volumes_client.show_volume(self.volume['id'])['volume']
        self.assertIn('available', body['status'])