'Perform the same checks that happen via SQL for in-memory managed
jobs.'

def __verify_in_memory_job_inputs(self, job):

    if (job.state == model.Job.states.DELETED):
        return JOB_DELETED
    elif (job.state == model.Job.states.ERROR):
        return JOB_ADMIN_DELETED
    for dataset_assoc in (job.input_datasets + job.input_library_datasets):
        idata = dataset_assoc.dataset
        if (not idata):
            continue
        if idata.deleted:
            self.job_wrappers.pop(job.id, self.job_wrapper(job)).fail(('input    data    %s    (file:    %s)    was    deleted    before    the    job    started' % (idata.hid, idata.file_name)))
            return JOB_INPUT_DELETED
        elif (idata.state == idata.states.ERROR):
            self.job_wrappers.pop(job.id, self.job_wrapper(job)).fail(('input    data    %s    is    in    error    state' % idata.hid))
            return JOB_INPUT_ERROR
        elif (idata.state == idata.states.FAILED_METADATA):
            self.job_wrappers.pop(job.id, self.job_wrapper(job)).fail(('input    data    %s    failed    to    properly    set    metadata' % idata.hid))
            return JOB_INPUT_ERROR
        elif ((idata.state != idata.states.OK) and (not ((idata.state == idata.states.SETTING_METADATA) and (job.tool_id is not None) and (job.tool_id == self.app.datatypes_registry.set_external_metadata_tool.id)))):
            return JOB_WAIT
    return None
