mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-04 13:14:24 -07:00
python_runner/django_command: bugfixes (#8944)
* python_runner/django_command: bugfixes * fix indentation * join path_prefix with : when concatenating with PATH * add changelog frag
This commit is contained in:
parent
ab84f1632f
commit
a7d1b0fc52
12 changed files with 349 additions and 2 deletions
91
tests/integration/targets/django_command/tasks/main.yaml
Normal file
91
tests/integration/targets/django_command/tasks/main.yaml
Normal file
|
@ -0,0 +1,91 @@
|
|||
# Test code for django_command module
|
||||
#
|
||||
# Copyright (c) 2020, Alexei Znamensky <russoz@gmail.com>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
- name: Create temporary test directory
|
||||
tempfile:
|
||||
state: directory
|
||||
suffix: .django_command
|
||||
register: tmp_django_root
|
||||
|
||||
- name: Install OS package virtualenv
|
||||
package:
|
||||
name: "{{ os_package_name.virtualenv }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure virtualenv is created
|
||||
command: >-
|
||||
virtualenv {{ tmp_django_root.path }}/venv
|
||||
|
||||
- name: Update python package pip
|
||||
pip:
|
||||
name: pip
|
||||
state: latest
|
||||
virtualenv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Install python package django
|
||||
pip:
|
||||
name: django
|
||||
state: present
|
||||
virtualenv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Copy files
|
||||
copy:
|
||||
src: base_test/
|
||||
dest: "{{ tmp_django_root.path }}"
|
||||
mode: preserve
|
||||
|
||||
- name: Create project
|
||||
command:
|
||||
chdir: "{{ tmp_django_root.path }}/startproj"
|
||||
cmd: "{{ tmp_django_root.path }}/venv/bin/django-admin startproject test_django_command_1"
|
||||
|
||||
- name: Create app
|
||||
command:
|
||||
chdir: "{{ tmp_django_root.path }}/startproj"
|
||||
cmd: "{{ tmp_django_root.path }}/venv/bin/django-admin startapp app1"
|
||||
|
||||
- name: Check
|
||||
community.general.django_command:
|
||||
pythonpath: "{{ tmp_django_root.path }}/startproj/test_django_command_1"
|
||||
settings: test_django_command_1.settings
|
||||
command: check
|
||||
venv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Check simple_project
|
||||
community.general.django_command:
|
||||
pythonpath: "{{ tmp_django_root.path }}/simple_project/p1"
|
||||
settings: p1.settings
|
||||
command: check
|
||||
venv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Check custom project
|
||||
community.general.django_command:
|
||||
pythonpath: "{{ tmp_django_root.path }}/1045-single-app-project/single_app_project"
|
||||
settings: core.settings
|
||||
command: check
|
||||
venv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Run collectstatic --noinput on simple project
|
||||
community.general.django_command:
|
||||
pythonpath: "{{ tmp_django_root.path }}/simple_project/p1"
|
||||
settings: p1.settings
|
||||
command: collectstatic --noinput
|
||||
venv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Trigger exception with environment variable
|
||||
community.general.django_command:
|
||||
pythonpath: "{{ tmp_django_root.path }}/simple_project/p1"
|
||||
settings: p1.settings
|
||||
command: collectstatic --noinput
|
||||
venv: "{{ tmp_django_root.path }}/venv"
|
||||
environment:
|
||||
DJANGO_ANSIBLE_RAISE: blah
|
||||
ignore_errors: true
|
||||
register: env_raise
|
||||
|
||||
- name: Check env variable reached manage.py
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'ValueError: DJANGO_ANSIBLE_RAISE=blah' in env_raise.msg"
|
Loading…
Add table
Add a link
Reference in a new issue