Prepare django for cypress
This commit is contained in:
parent
11d2bc3ed5
commit
8dd3316f8f
|
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$CI" ];
|
||||||
|
then
|
||||||
|
# kill all subprocess on exit
|
||||||
|
trap "exit" INT TERM ERR
|
||||||
|
trap "kill 0" EXIT
|
||||||
|
else echo "CI is set to $CI";
|
||||||
|
fi
|
||||||
|
|
||||||
|
# script should fail when any process returns non zero code
|
||||||
|
set -ev
|
||||||
|
|
||||||
|
# handle arguments
|
||||||
|
SKIP_SETUP=false
|
||||||
|
START_BACKGROUND=false
|
||||||
|
PROXY_VUE=false
|
||||||
|
|
||||||
|
for i in "$@"
|
||||||
|
do
|
||||||
|
case $i in
|
||||||
|
--start-background)
|
||||||
|
START_BACKGROUND=true
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
|
--skip-setup)
|
||||||
|
SKIP_SETUP=true
|
||||||
|
shift # past argument with no value
|
||||||
|
;;
|
||||||
|
--proxy-vue)
|
||||||
|
PROXY_VUE=true
|
||||||
|
shift # past argument with no value
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown option
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "SKIP_SETUP = ${SKIP_SETUP}"
|
||||||
|
|
||||||
|
DJANGO_SETTINGS_MODULE=config.settings.test_cypress
|
||||||
|
CYPRESS_DB=vbv_lernwelt_cypress
|
||||||
|
|
||||||
|
if [ "$SKIP_SETUP" = false ]; then
|
||||||
|
if [ -z "$PG_PORT" ]; then # if the port is set in the env, use it
|
||||||
|
DB_PORT="";
|
||||||
|
else
|
||||||
|
DB_PORT="-p $PG_PORT";
|
||||||
|
fi
|
||||||
|
if [ -z "$PG_USER" ]; then # if the user is set in the env, use it
|
||||||
|
DB_USER="";
|
||||||
|
else
|
||||||
|
DB_USER="-U $PG_USER";
|
||||||
|
fi
|
||||||
|
echo "psql -h localhost $DB_PORT $DB_USER -c 'drop database if exists $CYPRESS_DB;'"
|
||||||
|
# create database
|
||||||
|
psql -h localhost $DB_PORT $DB_USER -c "drop database if exists $CYPRESS_DB;"
|
||||||
|
psql -h localhost $DB_PORT $DB_USER -c "create database $CYPRESS_DB;"
|
||||||
|
|
||||||
|
# reset data
|
||||||
|
# python3 src/manage.py randomdata --settings="$DJANGO_SETTINGS_MODULE"
|
||||||
|
python3 server/manage.py createcachetable --settings="$DJANGO_SETTINGS_MODULE"
|
||||||
|
python3 server/manage.py migrate --settings="$DJANGO_SETTINGS_MODULE"
|
||||||
|
|
||||||
|
# make django translations
|
||||||
|
(cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE")
|
||||||
|
|
||||||
|
# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set API_WFM_BACKEND_ENABLED true
|
||||||
|
# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set TIBCO_SOAP_CUSTOMER_INTERACTION_CLIENT_ENABLED true
|
||||||
|
# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set API_EMAIL_MESSAGING_ENABLED true
|
||||||
|
# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set C4_NOTIFICATIONS_ENABLED true
|
||||||
|
# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set SFTP_POSTFINANCE_ENABLED true
|
||||||
|
# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set EASY_INSURANCE_AGENT_CAN_CREATE true
|
||||||
|
else
|
||||||
|
echo "else"
|
||||||
|
# python3 src/manage.py recreate_customer_data_for_integration_tests --settings="$DJANGO_SETTINGS_MODULE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PROXY_VUE" = true ]; then
|
||||||
|
export DJANGO_VUE_LANDINGPAGE_PROXY=http://localhost:8080/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# install cypress here to avoid problems with `npm install` on the iesc servers
|
||||||
|
CYPRESS_INSTALLED=0
|
||||||
|
#npx --no-install cypress --version || CYPRESS_INSTALLED=$?
|
||||||
|
if [ $CYPRESS_INSTALLED -ne 0 ]; then
|
||||||
|
echo "install cypress"
|
||||||
|
# npm install cypress@5.6.0 @testing-library/cypress@7.0.2 --no-save
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# the sftp server is currently not needed
|
||||||
|
# rm -rf test_sftp
|
||||||
|
# mkdir -p test_sftp
|
||||||
|
# (cd test_sftp && mkdir -p outbox && sftpserver -p 3373 -k ../src/myservice/apps/export/sftp_test_key.pem -l INFO &)
|
||||||
|
|
||||||
|
if [ "$START_BACKGROUND" = true ]; then
|
||||||
|
python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE" > /dev/null &
|
||||||
|
else
|
||||||
|
python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
|
||||||
|
import getpass
|
||||||
|
import os
|
||||||
|
|
||||||
|
from .base import * # noqa
|
||||||
|
from .base import env
|
||||||
|
|
||||||
|
# GENERAL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||||
|
SECRET_KEY = env(
|
||||||
|
"VBV_DJANGO_SECRET_KEY",
|
||||||
|
default="1LhwZ0DvP4cGBgbBdCfaBQV7eiaOc4jWKdzO9WEXLFT7AaqBN6jqd0uyaZeAZ19K",
|
||||||
|
)
|
||||||
|
|
||||||
|
# EMAIL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
||||||
|
|
||||||
|
CYPRESS_TEST = True
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
"default": {
|
||||||
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||||
|
"NAME": "vbv_lernwelt_cypress",
|
||||||
|
"USER": os.environ.get("PG_USER", getpass.getuser()),
|
||||||
|
"PASSWORD": os.environ.get("PG_PASSWORD"),
|
||||||
|
"HOST": "localhost",
|
||||||
|
"PORT": os.environ.get("PG_PORT", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Your stuff...
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# REST_FRAMEWORK['DEFAULT_THROTTLE_RATES'] = {
|
||||||
|
# 'anon': '100/day',
|
||||||
|
# 'hour-throttle': '40000/hour',
|
||||||
|
# 'day-throttle': '2000000/day',
|
||||||
|
# 'easy-throttle': '50000/day',
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# RATELIMIT_ENABLE = False
|
||||||
|
|
@ -1,8 +1,34 @@
|
||||||
<div class="container py-5">
|
{% extends "base.html" %}
|
||||||
<h1>Login</h1>
|
|
||||||
<form method="POST">
|
{% block content %}
|
||||||
{% csrf_token %}
|
|
||||||
{{ form }}
|
<div class="container mx-auto">
|
||||||
<button class="btn btn-primary" type="submit">Login</button>
|
|
||||||
</form>
|
<div class="w-full min-h-screen bg-gray-50 flex flex-col sm:justify-center items-center pt-6 sm:pt-0">
|
||||||
|
<div class="w-full sm:max-w-md p-5 mx-auto">
|
||||||
|
<h2 class="mb-12 text-center text-5xl font-extrabold">Login</h2>
|
||||||
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block mb-1" for="email">Username</label>
|
||||||
|
<input id="email" type="text" name="username" class="py-2 px-3 border border-gray-300 focus:border-red-300 focus:outline-none focus:ring focus:ring-red-200 focus:ring-opacity-50 rounded-md shadow-sm disabled:bg-gray-100 mt-1 block w-full"/>
|
||||||
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block mb-1" for="password">Password</label>
|
||||||
|
<input id="password" type="password" name="password" class="py-2 px-3 border border-gray-300 focus:border-red-300 focus:outline-none focus:ring focus:ring-red-200 focus:ring-opacity-50 rounded-md shadow-sm disabled:bg-gray-100 mt-1 block w-full"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-6">
|
||||||
|
<button
|
||||||
|
class="w-full inline-flex items-center justify-center px-4 py-2 bg-red-600 border border-transparent rounded-md font-semibold capitalize text-white hover:bg-red-700 active:bg-red-700 focus:outline-none focus:border-red-700 focus:ring focus:ring-red-200 disabled:opacity-25 transition"
|
||||||
|
type="submit">
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<div class="container mx-auto bg-blue-900">
|
||||||
|
<div class="flex flex-col md:flex-row items-center p-4 text-white space-x-8">
|
||||||
|
<div class="text-2xl mx-4">
|
||||||
|
<a href="/">
|
||||||
|
VBV Ausbildungsportal
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="/todo/">
|
||||||
|
SimpleTodo App
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div>Infos zu Berufen</div>
|
||||||
|
<div>Branchennews</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="container mx-auto">
|
<div class="container mx-auto">
|
||||||
<h1>Hello Todos</h1>
|
|
||||||
|
|
||||||
{% for list in simple_lists %}
|
{% for list in simple_lists %}
|
||||||
{% include "simpletodo/partials/simple_list.html" with list=list%}
|
{% include "simpletodo/partials/simple_list.html" with list=list%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ from vbv_lernwelt.simpletodo.serializers import SimpleTaskSerializer
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
simple_lists = SimpleList.objects.filter(user=request.user)
|
simple_lists = SimpleList.objects.filter(user=request.user)
|
||||||
|
|
||||||
|
if simple_lists.count() == 0:
|
||||||
|
simple_lists = [SimpleList.objects.create(user=request.user, title="Todos")]
|
||||||
|
|
||||||
return render(request, 'simpletodo/index.html', {
|
return render(request, 'simpletodo/index.html', {
|
||||||
'simple_lists': simple_lists
|
'simple_lists': simple_lists
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -34,17 +34,7 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="container mx-auto bg-blue-900">
|
{% include "core/partials/header.html" %}
|
||||||
<div class="flex flex-col md:flex-row items-center p-4 text-white space-x-8">
|
|
||||||
<div class="text-2xl mx-4">
|
|
||||||
VBV Ausbildungsportal
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>Kurse / Shop</div>
|
|
||||||
<div>Infos zu Berufen</div>
|
|
||||||
<div>Branchennews</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
|
@ -56,7 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div> <!-- /container -->
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue