prove that we catch those sphinx errors

This commit is contained in:
Jeff Balogh 2010-04-04 17:29:52 -07:00
Родитель 90c2a27d1c
Коммит 7ddcae47b3
1 изменённых файлов: 16 добавлений и 1 удалений

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

@ -3,14 +3,16 @@ Tests for the search (sphinx) app.
"""
import os
import shutil
import socket
import time
from django.test import TestCase, client
from django.core.management import call_command
from django.utils import translation
import mock
from nose import SkipTest
from nose.tools import eq_
from nose.tools import eq_, assert_raises
import test_utils
import amo.helpers
@ -113,6 +115,19 @@ class GetCategoryIdTest(TestCase):
query = lambda *args, **kwargs: SearchClient().query(*args, **kwargs)
@mock.patch('search.client.SphinxClient')
def test_sphinx_timeout(sphinx_mock):
def sphinx_error(cls):
raise cls
sphinx_mock.return_value = sphinx_mock
sphinx_mock.Query.side_effect = lambda *a: sphinx_error(socket.timeout)
assert_raises(SearchError, query, 'xxx')
sphinx_mock.Query.side_effect = lambda *a: sphinx_error(Exception)
assert_raises(SearchError, query, 'xxx')
class SearchDownTest(TestCase):
def test_search_down(self):