#!/bin/sh
# Superficial smoke test: confirm the widget can be imported and instantiated
# under a minimal Django environment.
set -eu

cd "$AUTOPKGTEST_TMP"

cat > settings.py <<'EOF'
SECRET_KEY = "autopkgtest"
INSTALLED_APPS = [
    "django.contrib.contenttypes",
    "django.contrib.auth",
    "django_json_widget",
]
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
USE_TZ = True
EOF

DJANGO_SETTINGS_MODULE=settings python3 - <<'EOF'
import django
django.setup()
from django_json_widget.widgets import JSONEditorWidget

widget = JSONEditorWidget()
assert widget.template_name == "django_json_widget.html"
assert "modes" in widget.options
print("OK")
EOF
