#!/bin/sh

set -e

ensure_files_exist() {
    for f in "$@"; do
	if [ ! -e $f ]; then
	    echo "ERROR: $f does not exist" >&2
	    exit 1
	else
	    echo "OK: $f is there"
	fi
    done
}

run() {
    echo "Running “$@”"
    $@
}

# Test startproject
cd $AUTOPKGTEST_TMP
run django-admin startproject testproject

ensure_files_exist testproject/manage.py testproject/testproject/settings.py

grep -qs python3 testproject/manage.py

# Test startapp
cd testproject
run django-admin startapp testapp

ensure_files_exist testapp/models.py testapp/tests.py testapp/views.py

# Test manage.py
#./manage.py check

python3 ./manage.py check
