#!/bin/sh

# Test that the module is importable. This test has been included
# instead of the standard autodep8 test as "import haystack" requires
# that the Django settings are configured.

set -e

# Create a minimal "settings.py" file with a valid haystack config,
# and use it as the Django settings file.
cat >> $AUTOPKGTEST_TMP/settings.py <<EOF
SECRET_KEY = 'foo'
INSTALLED_APPS = [
    'haystack',
]
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'
    }
}
EOF
export DJANGO_SETTINGS_MODULE=settings

# Attempt to import the package.
for py in $(py3versions -r 2>/dev/null) ; do
    cd "$AUTOPKGTEST_TMP" ;
    echo "Testing with $py:" ;
    $py -c "import haystack; print(haystack)" ;
done
