File: utils.py

package info (click to toggle)
django-haystack 3.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,512 kB
  • sloc: python: 23,577; xml: 1,708; makefile: 71; sh: 65
file content (18 lines) | stat: -rw-r--r-- 469 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import unittest

from django.conf import settings


def check_solr(using="solr"):
    try:
        from pysolr import Solr, SolrError
    except ImportError:
        raise unittest.SkipTest("pysolr not installed.")

    solr = Solr(settings.HAYSTACK_CONNECTIONS[using]["URL"])
    try:
        solr.search("*:*")
    except SolrError as e:
        raise unittest.SkipTest(
            "solr not running on %r" % settings.HAYSTACK_CONNECTIONS[using]["URL"], e
        )