#!/bin/sh
export PYTHONPATH="./"

if [ `which django-admin.py` ] ; then
    export DJANGO_ADMIN=django-admin.py
else
    export DJANGO_ADMIN=django-admin
fi

export args="$@"
if [ -z "$args" ] ; then
    # avoid running the tests for django.contrib.* (they're in INSTALLED_APPS)
    export args=myapp
fi

if [ "$args" = "myapp_i18n" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_i18n'
    APP="$args"
elif [ "$args" = "myapp_cms" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_cms'
    APP="myapp_cms"
elif [ "$args" = "myapp_all" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_all'
    APP="myapp_all"
else
    export DJANGO_SETTINGS_MODULE='settings'
    APP="$args"
fi

$DJANGO_ADMIN test --traceback --settings=$DJANGO_SETTINGS_MODULE --verbosity 2 --pythonpath="../" "$APP"
