def METHOD_NAME(entity, codename):
    """
    Checks the quantity of resources remaining before the quota is met
    Args:
        entity (User or TethysApp): the entity on which to check.
        codename (str): codename of the Quota to check
    Returns:
        dict (resource_available, units): Dictionary with two keys: resource_available(int) - amount of resource remaining, units(str) - units of amount, if applicable  # noqa: E501
    """
    from tethys_quotas.models import ResourceQuota
    try:
        rq = ResourceQuota.objects.get(codename=codename)
        rqh = rq.handler(entity)
        current_use = rqh.get_current_use()
    except ResourceQuota.DoesNotExist:
        log.warning(
            "Invalid Codename: ResourceQuota with codename {} does not exist.".format(
                codename
            )
        )
        return None
    total_available = get_quota(entity, codename)
    if total_available["quota"]:
        total_available = total_available["quota"]
        resource_available = total_available - current_use
    else:
        return None
    if resource_available < 0:
        resource_available = 0
    return {"resource_available": resource_available, "units": rq.units}