From 6ddd869722c51c1c296460a2516066a503561101 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Wed, 27 Dec 2017 19:33:29 +0100 Subject: [PATCH] add fixtures with test data --- Vagrantfile | 2 +- ansible/roles/web_AI-5/tasks/setup_script.sh | 2 + .../didgeridoo/webshop/fixtures/webshop.yaml | 97 +++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 django/didgeridoo/webshop/fixtures/webshop.yaml diff --git a/Vagrantfile b/Vagrantfile index 7e8c3d7..a8fe782 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -30,7 +30,7 @@ Vagrant.configure("2") do |config| #zu installierende Pakete apt-get install -y apache2 python3-django mariadb-server avahi-daemon \ libnss-mdns libapache2-mod-wsgi-py3 python3-mysqldb python3-pip - pip3 install django-extensions Pillow + pip3 install django-extensions Pillow pyaml /vagrant/ansible/roles/web_AI-5/tasks/setup_script.sh SHELL diff --git a/ansible/roles/web_AI-5/tasks/setup_script.sh b/ansible/roles/web_AI-5/tasks/setup_script.sh index d9ed1c3..6243fb4 100755 --- a/ansible/roles/web_AI-5/tasks/setup_script.sh +++ b/ansible/roles/web_AI-5/tasks/setup_script.sh @@ -17,3 +17,5 @@ echo "from django.contrib.auth.models import User; \ User.objects.filter(email='admin@example.com').delete(); \ User.objects.create_superuser('admin', 'admin@example.com', 'password')" | python3 /vagrant/django/didgeridoo/manage.py shell + +python3 /vagrant/django/didgeridoo/manage.py loaddata webshop diff --git a/django/didgeridoo/webshop/fixtures/webshop.yaml b/django/didgeridoo/webshop/fixtures/webshop.yaml new file mode 100644 index 0000000..a3c429d --- /dev/null +++ b/django/didgeridoo/webshop/fixtures/webshop.yaml @@ -0,0 +1,97 @@ +- model: webshop.Category + fields: + name: "First Parent Category" + parent_category: +- model: webshop.Category + fields: + name: "Second Parent Category" + parent_category: +- model: webshop.Category + fields: + name: "Third Parent Category" + parent_category: +- model: webshop.Category + fields: + name: "Fourth Parent Category" + parent_category: +- model: webshop.Category + fields: + name: "Child Category 1" + parent_category: 1 +- model: webshop.Category + fields: + name: "Child Category 2" + parent_category: 2 +- model: webshop.Category + fields: + name: "Child Category 3" + parent_category: 3 +- model: webshop.Category + fields: + name: "Child Category 4" + parent_category: 4 + +- model: webshop.Article + fields: + name: "Article of First Parent Category" + category: 1 + description: "An article sorted under the First Parent Category." + stock: 10 + status: 3 + price_in_chf: 10.1 +- model: webshop.Article + fields: + name: "Article of Second Parent Category" + category: 2 + description: "An article sorted under the Second Parent Category." + stock: 20 + status: 3 + price_in_chf: 20.2 +- model: webshop.Article + fields: + name: "Article of Third Parent Category" + category: 3 + description: "An article sorted under the Third Parent Category." + stock: 30 + status: 3 + price_in_chf: 30.3 +- model: webshop.Article + fields: + name: "Article of Fourth Parent Category" + category: 4 + description: "An article sorted under the Fourth Parent Category." + stock: 40 + status: 3 + price_in_chf: 40.4 +- model: webshop.Article + fields: + name: "Article of Child Category 1" + category: 5 + description: "An article sorted under the Child Category 1." + stock: 11 + status: 3 + price_in_chf: 11.1 +- model: webshop.Article + fields: + name: "Article of Child Category 2" + category: 6 + description: "An article sorted under the Child Category 2." + stock: 22 + status: 3 + price_in_chf: 21.2 +- model: webshop.Article + fields: + name: "Article of Child Category 3" + category: 7 + description: "An article sorted under the Child Category 3." + stock: 33 + status: 3 + price_in_chf: 31.3 +- model: webshop.Article + fields: + name: "Article of Child Category 4" + category: 8 + description: "An article sorted under the Child Category 4." + stock: 44 + status: 3 + price_in_chf: 41.4