Merge pull request #1147 from diox/remove-safe-signals

Remove safe signals (bug 865769)
This commit is contained in:
Mathieu Pillard 2013-09-18 04:48:00 -07:00
Родитель 31464a7b4f 4d5fa077dd
Коммит d4c71d51ae
9 изменённых файлов: 29 добавлений и 25 удалений

Просмотреть файл

@ -1,7 +1,6 @@
"""
Miscellaneous helpers that make Django compatible with AMO.
"""
import sys
import threading
from django.conf import settings

Просмотреть файл

@ -233,22 +233,16 @@ def days_ago(days):
return datetime.now().replace(microsecond=0) - timedelta(days=days)
class TestCase(RedisTest, test_utils.TestCase):
"""Base class for all amo tests."""
client_class = TestClient
class MockEsMixin(object):
mock_es = True
def shortDescription(self):
# Stop nose using the test docstring and instead the test method name.
pass
@classmethod
def setUpClass(cls):
if cls.mock_es:
start_es_mock()
try:
reset.send(None) # Reset all the ES tasks on hold.
super(TestCase, cls).setUpClass()
super(MockEsMixin, cls).setUpClass()
except Exception:
# We need to unpatch here because tearDownClass will not be
# called.
@ -259,11 +253,24 @@ class TestCase(RedisTest, test_utils.TestCase):
@classmethod
def tearDownClass(cls):
try:
super(TestCase, cls).tearDownClass()
super(MockEsMixin, cls).tearDownClass()
finally:
if cls.mock_es:
stop_es_mock()
class TestCase(MockEsMixin, RedisTest, test_utils.TestCase):
"""Base class for all amo tests."""
client_class = TestClient
def shortDescription(self):
# Stop nose using the test docstring and instead the test method name.
pass
def _post_teardown(self):
amo.set_user(None)
super(TestCase, self)._post_teardown()
def _pre_setup(self):
super(TestCase, self)._pre_setup()
cache.clear()

Просмотреть файл

@ -181,8 +181,12 @@ def update_price_currency(sender, instance, **kw):
if kw.get('raw'):
return
ids = list(instance.tier.addonpremium_set
.values_list('addon_id', flat=True))
try:
ids = list(instance.tier.addonpremium_set
.values_list('addon_id', flat=True))
except Price.DoesNotExist:
return
if ids:
log.info('Indexing {0} add-ons due to PriceCurrency changes'
.format(len(ids)))

Просмотреть файл

@ -105,9 +105,6 @@ djcelery.setup_loader()
from lib.log_settings_base import log_configure
log_configure()
from lib.misc import safe_signals
safe_signals.start_the_machine()
import django.conf
newrelic_ini = getattr(django.conf.settings, 'NEWRELIC_INI', None)
load_newrelic = False

Просмотреть файл

@ -37,6 +37,7 @@ from users.cron import reindex_users
from users.models import Group, GroupUser, UserProfile
@mock.patch.object(settings, 'TASK_USER_ID', 999)
class TestAcctSummary(TestCase):
fixtures = fixture('user_support_staff', 'user_999', 'webapp_337141',
'user_operator')

Просмотреть файл

@ -1033,7 +1033,7 @@ class TestEscalationQueue(AppReviewerTest, AccessMixin, FlagsMixin,
eq_(EscalationQueue.objects.filter(addon=app).exists(), False)
class TestReviewTransaction(AttachmentManagementMixin,
class TestReviewTransaction(AttachmentManagementMixin, amo.tests.MockEsMixin,
amo.tests.test_utils.TransactionTestCase):
fixtures = fixture('group_editor', 'user_editor', 'user_editor_group',
'webapp_337141')
@ -1066,8 +1066,6 @@ class TestReviewTransaction(AttachmentManagementMixin,
@mock.patch('lib.crypto.packaged.sign_app')
def test_public_sign_failure(self, sign_mock):
raise SkipTest('Passes locally, but fails on Jenkins :(')
self.app = self.get_app()
self.app.update(status=amo.STATUS_PENDING, is_packaged=True)
self.version = self.app.current_version

Просмотреть файл

@ -191,12 +191,11 @@ class ReviewBase(object):
self.version.update(has_info_request=True)
log.info(u'Sending request for information for %s to %s' %
(self.addon, emails))
data = self.get_context_data()
# Create thread.
self.create_comm_thread(action='info')
subject = u'Submission Update: %s' % data['name']
subject = u'Submission Update: %s' # notify_email will format this.
self.notify_email('info', subject)
def send_escalate_mail(self):
@ -355,7 +354,7 @@ class ReviewApp(ReviewBase):
if self.in_rereview:
RereviewQueue.objects.filter(addon=self.addon).delete()
self.create_comm_thread(action='disable')
subject = u'App disabled by reviewer: %s' % self.addon.name
subject = u'App disabled by reviewer: %s'
self.notify_email('disabled', subject)
self.log_action(amo.LOG.APP_DISABLED)

Просмотреть файл

@ -731,7 +731,7 @@ class TestPackagedModel(amo.tests.TestCase):
@mock.patch.object(settings, 'SITE_URL', 'http://hy.fr')
@mock.patch('lib.crypto.packaged.os.unlink', new=mock.Mock)
def test_create_blocklisted_version(self):
app = app_factory(name='Mozillaball ょ', app_slug='test',
app = app_factory(name=u'Mozillaball ょ', app_slug='test',
is_packaged=True, version_kw={'version': '1.0',
'created': None})
app.create_blocklisted_version()

Просмотреть файл

@ -6,14 +6,13 @@ from django.core import mail
from mock import patch
from nose.tools import eq_, ok_
from waffle.models import Flag
from amo import CONTRIB_PENDING, CONTRIB_PURCHASE
from amo.tests import TestCase
from amo.urlresolvers import reverse
from constants.payments import PROVIDER_BANGO
from market.models import Price, PriceCurrency
from users.models import UserProfile
from users.models import UserProfile, GroupUser
from mkt.api.base import get_url, list_url
from mkt.api.tests.test_oauth import BaseOAuth
@ -235,7 +234,7 @@ class TestNotification(BaseOAuth):
eq_(msg.recipients(), [u'steamcube@mozilla.com'])
def test_no_permission(self):
self.profile.groups.all().delete()
GroupUser.objects.filter(user=self.profile).delete()
res = self.client.patch(self.get_url, data=json.dumps({}))
eq_(res.status_code, 401)