From 77b35d065fe1244060318633a6e4dd08f8dacba6 Mon Sep 17 00:00:00 2001 From: Andy McKay Date: Fri, 24 Aug 2012 12:12:51 -0700 Subject: [PATCH] stop inapp blowing up amo tests --- apps/amo/tests/__init__.py | 5 +++-- apps/zadmin/views.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/amo/tests/__init__.py b/apps/amo/tests/__init__.py index 42d3be9abd..e0bfd7bd52 100644 --- a/apps/amo/tests/__init__.py +++ b/apps/amo/tests/__init__.py @@ -27,7 +27,6 @@ from waffle.models import Flag, Sample, Switch import addons.search import amo -import mkt.stats.search import stats.search from access.models import Group, GroupUser from addons.models import Addon, AddonCategory, Category, Persona @@ -563,7 +562,9 @@ class ESTestCase(TestCase): addons.search.setup_mapping() stats.search.setup_indexes() - mkt.stats.search.setup_mkt_indexes() + if settings.MARKETPLACE: + import mkt.stats.search + mkt.stats.search.setup_mkt_indexes() @classmethod def setUpIndex(cls): diff --git a/apps/zadmin/views.py b/apps/zadmin/views.py index 41fe1ad3d2..7575b4a601 100644 --- a/apps/zadmin/views.py +++ b/apps/zadmin/views.py @@ -41,8 +41,6 @@ from devhub.models import ActivityLog from files.models import Approval, File from files.tasks import start_upgrade as start_upgrade_task from files.utils import find_jetpacks, JetpackUpgrader -from mkt.stats.cron import index_latest_mkt_stats, index_mkt_stats -from mkt.stats.search import setup_mkt_indexes from stats.cron import index_latest_stats from stats.search import setup_indexes from users.cron import reindex_users @@ -61,6 +59,15 @@ from .models import EmailPreviewTopic, ValidationJob, ValidationJobTally log = commonware.log.getLogger('z.zadmin') +# This causes AMO problems if inapp gets imported. Then cache machine tries +# to query it to see if it exists. +if settings.MARKETPLACE and settings.IN_TEST_SUITE: + from mkt.stats.cron import index_latest_mkt_stats, index_mkt_stats + from mkt.stats.search import setup_mkt_indexes +else: + index_latest_mkt_stats, index_mkt_stats = None, None + setup_mkt_indexes = None + @admin_required(reviewers=True) def flagged(request):