TT#121955 repoapi: don't use send_task directly

Change-Id: Iffcd0c084281158106d8c582930331f841af9757
pull/5/head
Victor Seva 4 years ago
parent d832e3233c
commit e4aa31a7e3

@ -1,4 +1,4 @@
# Copyright (C) 2016-2020 The Sipwise Team - http://sipwise.com
# Copyright (C) 2016-2022 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -92,3 +92,10 @@ def receiver_setup_logging(loglevel, logfile, format, colorize, **kwargs):
@app.task()
def jbi_parse_hotfix(jbi_id, path):
app.send_task("hotfix.tasks.hotfix_released", args=[jbi_id, path])
@app.task()
def process_result(jbi_id, path_envVars):
app.send_task(
"release_changed.tasks.process_result", args=[jbi_id, path_envVars]
)

@ -19,8 +19,8 @@ import structlog
from celery import shared_task
from django.apps import apps
from .celery import app
from .celery import jbi_parse_hotfix
from .celery import process_result
from .conf import settings
from .utils import is_download_artifacts
from .utils import jenkins_get_artifact
@ -77,9 +77,7 @@ def get_jbi_files(jbi_id, jobname, buildnumber):
else:
log.debug("skip artifacts download")
if jobname in settings.RELEASE_CHANGED_JOBS:
app.send_task(
"release_changed.tasks.process_result", args=[jbi_id, path_envVars]
)
process_result.delay(jbi_id, path_envVars)
@shared_task(ignore_result=True)

@ -140,8 +140,8 @@ class TestJBICelery(BaseTest):
class TestJBIReleaseChangedCelery(BaseTest):
@patch("builtins.open", mock_open(read_data=artifacts_json))
@patch("repoapi.utils.dlfile")
@patch("repoapi.tasks.app")
def test_jbi_release_changed(self, app, dlfile):
@patch("repoapi.tasks.process_result")
def test_jbi_release_changed(self, process_result, dlfile):
param = {
"projectname": "check-ngcp-release-changes",
"jobname": "check-ngcp-release-changes",
@ -157,6 +157,4 @@ class TestJBIReleaseChangedCelery(BaseTest):
)
path = base_path.joinpath("envVars.json")
dlfile.assert_any_call(url, path)
app.send_task.assert_called_once_with(
"release_changed.tasks.process_result", args=[jbi.id, path]
)
process_result.delay.assert_called_once_with(jbi.id, path)

Loading…
Cancel
Save