mirror of https://github.com/sipwise/repoapi.git
> https://docs.celeryproject.org/en/latest/django/first-steps-with-django.html Change-Id: If66605b4675a6896f9bd5c387d300255ea7d368achanges/14/38714/1
parent
44b0cdc640
commit
9b591bf435
@ -1,27 +1,25 @@
|
|||||||
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
|
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
|
||||||
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
# 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
|
# under the terms of the GNU General Public License as published by the Free
|
||||||
# Software Foundation, either version 3 of the License, or (at your option)
|
# Software Foundation, either version 3 of the License, or (at your option)
|
||||||
# any later version.
|
# any later version.
|
||||||
|
#
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
# more details.
|
# more details.
|
||||||
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
||||||
# with this prograproj. If not, see <http://www.gnu.org/licenses/>.
|
# with this prograproj. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
from django.test import TestCase
|
||||||
|
from mock import patch
|
||||||
|
|
||||||
from django.test import TestCase, override_settings
|
|
||||||
from release_dashboard import tasks
|
from release_dashboard import tasks
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
|
|
||||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True)
|
|
||||||
class TasksBuildTestCase(TestCase):
|
class TasksBuildTestCase(TestCase):
|
||||||
|
@patch("release_dashboard.tasks.gerrit_fetch_info")
|
||||||
@patch('release_dashboard.tasks.gerrit_fetch_info')
|
|
||||||
def test_gerrit_fetch_all(self, gfi):
|
def test_gerrit_fetch_all(self, gfi):
|
||||||
result = tasks.gerrit_fetch_all.delay()
|
result = tasks.gerrit_fetch_all.delay()
|
||||||
self.assertTrue(result.successful())
|
self.assertTrue(result.successful())
|
||||||
|
|||||||
@ -1,19 +1,20 @@
|
|||||||
# Copyright (C) 2016 The Sipwise Team - http://sipwise.com
|
# Copyright (C) 2016 The Sipwise Team - http://sipwise.com
|
||||||
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
# 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
|
# under the terms of the GNU General Public License as published by the Free
|
||||||
# Software Foundation, either version 3 of the License, or (at your option)
|
# Software Foundation, either version 3 of the License, or (at your option)
|
||||||
# any later version.
|
# any later version.
|
||||||
|
#
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
# more details.
|
# more details.
|
||||||
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from __future__ import absolute_import
|
from .celery import app as celery_app
|
||||||
|
|
||||||
# This will make sure the app is always imported when
|
# This will make sure the app is always imported when
|
||||||
# Django starts so that shared_task will use this app.
|
# Django starts so that shared_task will use this app.
|
||||||
from .celery import app as celery_app # noqa
|
|
||||||
|
__all__ = ("celery_app",)
|
||||||
|
|||||||
@ -1,35 +1,36 @@
|
|||||||
# Copyright (C) 2016 The Sipwise Team - http://sipwise.com
|
# Copyright (C) 2016 The Sipwise Team - http://sipwise.com
|
||||||
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
# 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
|
# under the terms of the GNU General Public License as published by the Free
|
||||||
# Software Foundation, either version 3 of the License, or (at your option)
|
# Software Foundation, either version 3 of the License, or (at your option)
|
||||||
# any later version.
|
# any later version.
|
||||||
|
#
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
# more details.
|
# more details.
|
||||||
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'repoapi.settings.prod')
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "repoapi.settings.prod")
|
||||||
# pylint: disable=C0413
|
|
||||||
from django.conf import settings # noqa
|
app = Celery("repoapi")
|
||||||
|
|
||||||
app = Celery('repoapi')
|
# Using a string here means the worker doesn't have to serialize
|
||||||
|
# the configuration object to child processes.
|
||||||
|
# - namespace='CELERY' means all celery-related configuration keys
|
||||||
|
# should have a `CELERY_` prefix.
|
||||||
|
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||||
|
|
||||||
# Using a string here means the worker will not have to
|
# Load task modules from all registered Django app configs.
|
||||||
# pickle the object when using Windows.
|
app.autodiscover_tasks()
|
||||||
app.config_from_object('django.conf:settings')
|
|
||||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
|
||||||
|
|
||||||
|
|
||||||
@app.task()
|
@app.task()
|
||||||
def jbi_parse_hotfix(jbi_id, path):
|
def jbi_parse_hotfix(jbi_id, path):
|
||||||
app.send_task('hotfix.tasks.hotfix_released', args=[jbi_id, path])
|
app.send_task("hotfix.tasks.hotfix_released", args=[jbi_id, path])
|
||||||
|
|||||||
Loading…
Reference in new issue