Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Revert "Make fetch_bugs a periodic task."
Browse files Browse the repository at this point in the history
  • Loading branch information
akatsoulas committed Mar 27, 2015
1 parent 33cf492 commit 73f908d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
14 changes: 2 additions & 12 deletions remo/remozilla/tasks.py
Expand Up @@ -8,7 +8,7 @@

import requests
import waffle
from celery.task import periodic_task, task
from celery.task import task
from funfactory.helpers import urlparams

from remo.base.utils import get_object_or_none
Expand Down Expand Up @@ -41,18 +41,8 @@ def parse_bugzilla_time(time):


@task
def fetch_bugs(components=COMPONENTS, days=None):
""" This task is deprecated.
This used to run through cron on the server and it will be
removed completely when the cron entry is removed.
"""
return


@periodic_task(run_every=timedelta(minutes=15))
@transaction.commit_on_success
def fetch_remo_bugs(components=COMPONENTS, days=None):
def fetch_bugs(components=COMPONENTS, days=None):
"""Fetch all bugs from Bugzilla.
Loop over components and fetch bugs updated the last days. Link
Expand Down
14 changes: 7 additions & 7 deletions remo/remozilla/tests/test_tasks.py
Expand Up @@ -11,7 +11,7 @@

from remo.profiles.tests import UserFactory
from remo.remozilla.models import Bug
from remo.remozilla.tasks import fetch_remo_bugs
from remo.remozilla.tasks import fetch_bugs
from remo.remozilla.utils import get_last_updated_date


Expand All @@ -22,19 +22,19 @@ class FetchBugsTest(TestCase):
@raises(requests.ConnectionError)
@patch('requests.get')
def test_connection_error(self, fake_get):
"""Test fetch_remo_bugs connection error exception."""
"""Test fetch_bugs connection error exception."""
if ((not getattr(settings, 'REMOZILLA_USERNAME', None) or
not getattr(settings, 'REMOZILLA_PASSWORD', None))):
raise SkipTest('Skipping test due to unset REMOZILLA_USERNAME '
'or REMOZILLA_PASSWORD.')
fake_get.side_effect = requests.ConnectionError()
fetch_remo_bugs()
fetch_bugs()
fake_get.assert_called_with(ANY)

@raises(ValueError)
@patch('remo.remozilla.tasks.requests')
def test_invalid_return_code(self, mocked_request):
"""Test fetch_remo_bugs invalid status code exception."""
"""Test fetch_bugs invalid status code exception."""
if ((not getattr(settings, 'REMOZILLA_USERNAME', None) or
not getattr(settings, 'REMOZILLA_PASSWORD', None))):
raise SkipTest('Skipping test due to unset REMOZILLA_USERNAME '
Expand All @@ -43,12 +43,12 @@ def test_invalid_return_code(self, mocked_request):
mocked_request.get.return_value = mocked_obj
mocked_response = mocked_obj
mocked_response.json.return_value = {'error': 'Invalid login'}
fetch_remo_bugs()
fetch_bugs()

@patch('remo.remozilla.tasks.waffle.switch_is_active')
@patch('remo.remozilla.tasks.requests.get')
def test_with_valid_data(self, mocked_request, switch_is_active_mock):
"""Test fetch_remo_bugs valid bug data processing."""
"""Test fetch_bugs valid bug data processing."""
UserFactory.create(username='remobot')
if ((not getattr(settings, 'REMOZILLA_USERNAME', None) or
not getattr(settings, 'REMOZILLA_PASSWORD', None))):
Expand Down Expand Up @@ -110,7 +110,7 @@ def mocked_get(url, *args, **kwargs):
return mocked_response

mocked_request.side_effect = mocked_get
fetch_remo_bugs()
fetch_bugs()

eq_(Bug.objects.all().count(), 2)
eq_(Bug.objects.filter(component='Budget Requests').count(), 2)
Expand Down

0 comments on commit 73f908d

Please sign in to comment.