1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-26 15:07:32 +00:00
community.general/tests/integration/targets/python_runner/tasks/main.yml
patchback[bot] fa682e8b40
[PR #11638/4f5e5c9b backport][stable-12] python_runner: add integration tests (#11643)
test(python_runner): add integration tests (#11638)

* test(python_runner): add integration tests

* simplify the test

* add missing quotes

* use setup_remote_tmp_dir

* build venv manually first

(cherry picked from commit 4f5e5c9bb6)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
2026-03-22 11:17:12 +01:00

43 lines
1.6 KiB
YAML

# Copyright (c) 2026, 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 virtualenv
ansible.builtin.command:
cmd: "{{ ansible_python_interpreter }} -m venv {{ remote_tmp_dir }}/venv"
- name: Update pip in virtualenv
ansible.builtin.pip:
name: pip
state: latest
virtualenv: "{{ remote_tmp_dir }}/venv"
- name: Install django in virtualenv
ansible.builtin.pip:
name: django
state: present
virtualenv: "{{ remote_tmp_dir }}/venv"
# Regression test for https://github.com/ansible-collections/community.general/issues/8884
# Bug: PythonRunner was setting path_prefix to a string instead of a list, corrupting PATH
# when venv was specified, so the venv's python could not be found.
# The original reporter was running `migrate`; we use `check` to avoid needing a database.
- name: Create Django project using venv django-admin
ansible.builtin.command:
cmd: "{{ remote_tmp_dir }}/venv/bin/django-admin startproject testproject"
chdir: "{{ remote_tmp_dir }}"
- name: Run django_command check on the created project (issue 8884 scenario)
community.general.django_command:
command: check
settings: testproject.settings
pythonpath: "{{ remote_tmp_dir }}/testproject"
venv: "{{ remote_tmp_dir }}/venv"
register: result_project_check
- name: Assert project check succeeded and returned a version
ansible.builtin.assert:
that:
- result_project_check is success
- result_project_check.version is defined
- result_project_check.version != ""