Esempio n. 1
0
def get_job_for_service(service_id, job_id=None):
    if job_id:
        try:
            job = get_job(service_id, job_id)
            data, errors = job_schema.dump(job)
            return jsonify(data=data)
        except DataError:
            return jsonify(result="error", message="Invalid job id"), 400
        except NoResultFound:
            return jsonify(result="error", message="Job not found"), 404
    else:
        jobs = get_jobs_by_service(service_id)
        data, errors = jobs_schema.dump(jobs)
        return jsonify(data=data)
Esempio n. 2
0
def get_job_for_service(service_id, job_id=None):
    if job_id:
        try:
            job = get_job(service_id, job_id)
            data, errors = job_schema.dump(job)
            return jsonify(data=data)
        except DataError:
            return jsonify(result="error", message="Invalid job id"), 400
        except NoResultFound:
            return jsonify(result="error", message="Job not found"), 404
    else:
        jobs = get_jobs_by_service(service_id)
        data, errors = jobs_schema.dump(jobs)
        return jsonify(data=data)
def test_get_job_by_id(notify_db, notify_db_session, sample_job):
    job_from_db = get_job(sample_job.service.id, sample_job.id)
    assert sample_job == job_from_db