'Make assertions common to all API responses.'

def assertValidResponse(self, resp, key, entity_validator, *args, **kwargs):

    entity = resp.result.get(key)
    self.assertIsNotNone(entity)
    keys = kwargs.pop('keys_to_check', None)
    self.assertValidEntity(entity, keys_to_check=keys, *args, **kwargs)
    entity_validator(entity, *args, **kwargs)
    return entity
