Beispiel #1
0
    def run_task(self, task):
        """Actually run a task, inserting a DB row and generating the celery task."""
        job = tables.BadpennyJob(task_id=task.task_id, created_at=time.now())
        current_app.db.session('relengapi').add(job)
        current_app.db.session('relengapi').commit()

        execution.submit_job(task_name=task.name, job_id=job.id)
Beispiel #2
0
    def run_task(self, task):
        """Actually run a task, inserting a DB row and generating the celery task."""
        job = tables.BadpennyJob(
            task_id=task.task_id,
            created_at=time.now())
        current_app.db.session('relengapi').add(job)
        current_app.db.session('relengapi').commit()

        execution.submit_job(task_name=task.name, job_id=job.id)
Beispiel #3
0
def run_task_now(task_name):
    """Force the given badpenny task to run now."""
    t = tables.BadpennyTask.query.filter(
        tables.BadpennyTask.name == task_name).first()
    if not t:
        raise NotFound

    session = current_app.db.session('relengapi')
    job = tables.BadpennyJob(task=t, created_at=time.now())
    session.add(job)
    session.commit()

    execution.submit_job(task_name=t.name, job_id=job.id)
    return job.to_jsonjob()
Beispiel #4
0
def run_task_now(task_name):
    """Force the given badpenny task to run now."""
    t = tables.BadpennyTask.query.filter(
        tables.BadpennyTask.name == task_name).first()
    if not t:
        raise NotFound

    session = current_app.db.session('relengapi')
    job = tables.BadpennyJob(task=t, created_at=time.now())
    session.add(job)
    session.commit()

    execution.submit_job(task_name=t.name, job_id=job.id)
    return job.to_jsonjob()
def test_submit_job():
    """`execution.submit_job` just invokes _run_job via Celery"""
    with mock.patch('relengapi.blueprints.badpenny.execution._run_job') as _run_job:
        execution.submit_job('foo', 10)
        _run_job.delay.assert_called_with('foo', 10)
Beispiel #6
0
def test_submit_job():
    """`execution.submit_job` just invokes _run_job via Celery"""
    with mock.patch(
            'relengapi.blueprints.badpenny.execution._run_job') as _run_job:
        execution.submit_job('foo', 10)
        _run_job.delay.assert_called_with('foo', 10)