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

Commit

Permalink
Remove raven.contrib.celery.CeleryClient
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Dec 10, 2013
1 parent 6032462 commit 6c5afbf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 116 deletions.
10 changes: 0 additions & 10 deletions docs/config/celery.rst

This file was deleted.

32 changes: 9 additions & 23 deletions raven/contrib/celery/__init__.py
Expand Up @@ -2,39 +2,25 @@
raven.contrib.celery
~~~~~~~~~~~~~~~~~~~~
>>> class CeleryClient(CeleryMixin, Client):
>>> def send_encoded(self, *args, **kwargs):
>>> "Errors through celery"
>>> self.send_raw.delay(*args, **kwargs)
>>> @task(routing_key='sentry')
>>> def send_raw(*args, **kwargs):
>>> return super(client, self).send_encoded(*args, **kwargs)
:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import

import logging
try:
from celery.contrib.methods import task
except ImportError:
# Import the pre Celery 3.1 tasks (At some point we'll drop that)
try:
from celery.task import task
except ImportError:
from celery.decorators import task # NOQA
from celery.signals import after_setup_logger, task_failure
from raven.base import Client
from raven.handlers.logging import SentryHandler


class CeleryMixin(object):
def send_encoded(self, *args, **kwargs):
"Errors through celery"
self.send_raw.delay(*args, **kwargs)

@task(routing_key='sentry')
def send_raw(self, *args, **kwargs):
return super(CeleryMixin, self).send_encoded(*args, **kwargs)


class CeleryClient(CeleryMixin, Client):
pass


class CeleryFilter(logging.Filter):
def filter(self, record):
# Context is fixed in Celery 3.x so use internal flag instead
Expand Down
13 changes: 3 additions & 10 deletions raven/contrib/django/celery/__init__.py
Expand Up @@ -7,25 +7,18 @@
"""
from __future__ import absolute_import

from raven.contrib.celery import CeleryMixin
from raven.contrib.django.client import DjangoClient
try:
from celery.contrib.methods import task
from celery.task import task
except ImportError:
# Import the pre Celery 3.1 tasks (At some point we'll drop that)
try:
from celery.task import task
except ImportError:
from celery.decorators import task # NOQA
from celery.decorators import task # NOQA


class CeleryClient(CeleryMixin, DjangoClient):

class CeleryClient(DjangoClient):
def send_integrated(self, kwargs):
return send_raw_integrated.delay(kwargs)

def send_encoded(self, *args, **kwargs):
"Errors through celery"
return send_raw.delay(*args, **kwargs)


Expand Down
Empty file removed tests/contrib/celery/__init__.py
Empty file.
44 changes: 0 additions & 44 deletions tests/contrib/celery/tests.py

This file was deleted.

29 changes: 0 additions & 29 deletions tests/contrib/django/tests.py
Expand Up @@ -12,7 +12,6 @@
import re
import sys # NOQA
from exam import fixture
from celery.app import app_or_default

from django.conf import settings
from django.core.exceptions import SuspiciousOperation
Expand Down Expand Up @@ -594,20 +593,6 @@ def test_without_eager(self, send_raw):

self.assertEquals(send_raw.delay.call_count, 1)

# @with_eager_tasks
@mock.patch('raven.contrib.django.DjangoClient.send_encoded')
def test_with_eager(self, send_encoded):
"""
Integration test to ensure it propagates all the way down
and calls the parent client's send_encoded method.
"""
celery_app = app_or_default()
celery_app.conf.CELERY_ALWAYS_EAGER = True
self.client.captureMessage(message='test')

self.assertEquals(send_encoded.call_count, 1)
celery_app.conf.CELERY_ALWAYS_EAGER = False


class CeleryIntegratedClientTest(TestCase):
def setUp(self):
Expand All @@ -631,20 +616,6 @@ def test_without_eager(self, send_raw):

self.assertEquals(send_raw.delay.call_count, 1)

# @with_eager_tasks
@mock.patch('raven.contrib.django.DjangoClient.send_encoded')
def test_with_eager(self, send_encoded):
"""
Integration test to ensure it propagates all the way down
and calls the parent client's send_encoded method.
"""
celery_app = app_or_default()
celery_app.conf.CELERY_ALWAYS_EAGER = True
self.client.captureMessage(message='test')

self.assertEquals(send_encoded.call_count, 1)
celery_app.conf.CELERY_ALWAYS_EAGER = False


class IsValidOriginTestCase(TestCase):
def test_setting_empty(self):
Expand Down

0 comments on commit 6c5afbf

Please sign in to comment.