#!/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_cms30" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_cms30'
    APP="myapp_cms"
elif [ "$args" = "myapp_i18n" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_i18n'
    APP="$args"
elif [ "$args" = "myapp_all30" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_all30'
    APP="myapp_all"
elif [ "$args" = "myapp_cms31" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_cms31'
    APP="myapp_cms"
elif [ "$args" = "myapp_all31" ] ; then
    export DJANGO_SETTINGS_MODULE='settings_all31'
    APP="myapp_all"
else
    export DJANGO_SETTINGS_MODULE='settings'
    APP="$args"
fi

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