def test_parser_for_simple_backend():
    config = dj_haystack_url.parse('simple')
    expected = {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    }

    assert config == expected
def test_parser_for_solr_backend():
    config = dj_haystack_url.parse('solr:http://127.0.0.1:8983/solr')
    expected = {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr',
    }

    assert config == expected
def test_parser_for_whoosh_backend_with_relative_path():
    config = dj_haystack_url.parse('whoosh:relative/path/to/whoosh_index')
    expected = {
        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
        'PATH': 'relative/path/to/whoosh_index',
    }

    assert config == expected
def test_parser_for_xapian_backend_with_relative_path():
    config = dj_haystack_url.parse('xapian:relative/path/to/xapian_index')
    expected = {
        'ENGINE': 'xapian_backend.XapianEngine',
        'PATH': 'relative/path/to/xapian_index',
    }

    assert config == expected
def test_parser_for_elasticsearch_backend():
    config = dj_haystack_url.parse('elasticsearch:http://127.0.0.1:9200/haystack')
    expected = {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200',
        'INDEX_NAME': 'haystack',
    }

    assert config == expected
def test_parser_for_whoosh_backend_with_user_home_in_path():
    config = dj_haystack_url.parse('whoosh:~/path/under/home/dir')
    home_dir = os.path.expanduser('~')
    expected = {
        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
        'PATH': os.path.join(home_dir, 'path/under/home/dir'),
    }

    assert config == expected
def test_parser_for_xapian_backend_with_user_home_in_path():
    config = dj_haystack_url.parse('xapian:~/path/under/home/dir')
    home_dir = os.path.expanduser('~')
    expected = {
        'ENGINE': 'xapian_backend.XapianEngine',
        'PATH': os.path.join(home_dir, 'path/under/home/dir'),
    }

    assert config == expected
def test_parser_for_invalid_elasticsearch_url():
    with pytest.raises(ValueError) as err:
        dj_haystack_url.parse('elasticsearch:')

    assert str(err.value) == 'URL and INDEX_NAME are required for the elasticsearch backend'
Esempio n. 9
0
    __file__) + '/local/database.sqlite'
DATABASE_URL = get_env_variable('DATABASE_URL', DEFAULT_DATABASE_URL)
DATABASES = {'default': dj_database_url.parse(DATABASE_URL)}
if DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
    DATABASES['default']['OPTIONS'][
        'charset'] = 'utf8mb4'  # MySQL's true Unicode character set
import django_cache_url
CACHE_URL = get_env_variable('CACHE_URL', default="locmem://opendataiscool")
CACHES = {'default': django_cache_url.parse(CACHE_URL)}

import dj_haystack_url
HAYSTACK_CONNECTIONS = {
    'default': { # required but not used
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
    'person': dj_haystack_url.parse(get_env_variable('HAYSTACK_PERSON_CONNECTION', default='xapian:local/xapian_index_person')),
    'bill': dj_haystack_url.parse(get_env_variable('HAYSTACK_BILL_CONNECTION', default='xapian:local/xapian_index_bill')),
}

from django.utils.crypto import get_random_string
default_secret_key = get_random_string(
    50, 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
SECRET_KEY = get_env_variable('SECRET_KEY', default=default_secret_key)

RSS_CAMPAIGN_QUERYSTRING = get_env_variable(
    'RSS_CAMPAIGN_QUERYSTRING',
    default=
    "?utm_campaign=govtrack_feed&utm_source=govtrack/feed&utm_medium=rss")

# Copy some environment variables into the Django settings object.
copy_env_vars = [
def test_parser_for_invalid_solr_url():
    with pytest.raises(ValueError) as err:
        dj_haystack_url.parse('solr:')

    assert str(err.value) == 'URL value cannot be empty for the the solr backend'
Esempio n. 11
0
DATABASE_URL = get_env_variable('DATABASE_URL', DEFAULT_DATABASE_URL)
DATABASES = {
	'default': dj_database_url.parse(DATABASE_URL)
}
import django_cache_url
CACHE_URL = get_env_variable('CACHE_URL', default="locmem://opendataiscool")
CACHES = {
	'default': django_cache_url.parse(CACHE_URL)
}

import dj_haystack_url
HAYSTACK_CONNECTIONS = {
    'default': { # required but not used
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
    'person': dj_haystack_url.parse(get_env_variable('HAYSTACK_PERSON_CONNECTION', default='xapian:local/xapian_index_person')),
    'bill': dj_haystack_url.parse(get_env_variable('HAYSTACK_BILL_CONNECTION', default='xapian:local/xapian_index_bill')),
}

from django.utils.crypto import get_random_string
default_secret_key = get_random_string(50, 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
SECRET_KEY = get_env_variable('SECRET_KEY', default=default_secret_key)

RSS_CAMPAIGN_QUERYSTRING = get_env_variable('RSS_CAMPAIGN_QUERYSTRING', default="?utm_campaign=govtrack_feed&utm_source=govtrack/feed&utm_medium=rss")


# Copy some environment variables into the Django settings object.
copy_env_vars = [
    # For accounts logic.
    "RECAPTCHA_SITE_KEY",
    "RECAPTCHA_SECRET_KEY",
def test_parser_for_invalid_solr_url():
    with pytest.raises(ValueError) as err:
        dj_haystack_url.parse('whoosh:')

    assert str(err.value) == 'PATH value cannot be empty for the whoosh backend'