mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Django integration tests (#1607)
* added integration test for module django_manage * Initial attempt at integration tests for django_manage * added ignore lines for django python code * added more ignore lines for django python code * removed a couple of extraneous files and ignore lines * also removed urls.py, as it is not required for testing * added test group to aliases file * Adding a few lines attempting to remove py2 from the equation. * restricted integration tests platforms * restricted integration tests platforms (moving to aliases) * foce using a virtualenv for the test, to avoid differences in different OSes * Adding urls.py back to the test project * Adding ignore lines for urls.py * Updated aliases for the testing
This commit is contained in:
parent
f1a31611b7
commit
b9408dc8ef
12 changed files with 272 additions and 0 deletions
6
tests/integration/targets/django_manage/aliases
Normal file
6
tests/integration/targets/django_manage/aliases
Normal file
|
@ -0,0 +1,6 @@
|
|||
shippable/posix/group2
|
||||
skip/python2
|
||||
skip/freebsd
|
||||
skip/macos
|
||||
skip/osx
|
||||
skip/rhel8.2
|
|
@ -0,0 +1,2 @@
|
|||
# single_app_project/core/settings.py
|
||||
SECRET_KEY = 'testtesttesttesttest'
|
|
@ -0,0 +1,12 @@
|
|||
#! /usr/bin/env python3
|
||||
# single_app_project/manage.py
|
||||
import os
|
||||
import sys
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'single_app_project.core.settings')
|
||||
from django.core.management import execute_from_command_line
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'p1.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -0,0 +1,120 @@
|
|||
"""
|
||||
Django settings for p1 project.
|
||||
|
||||
Generated by 'django-admin startproj' using Django 3.1.5.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '%g@gyhl*q@@g(_ab@t^76dao^#b9-v8mw^50)x_bv6wpl+mukj'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'p1.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'p1.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/3.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
|
@ -0,0 +1,21 @@
|
|||
"""p1 URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
50
tests/integration/targets/django_manage/tasks/main.yaml
Normal file
50
tests/integration/targets/django_manage/tasks/main.yaml
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Test code for django_manage module
|
||||
#
|
||||
# Copyright: (c) 2020, Alexei Znamensky <russoz@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
- name: Create temporary test directory
|
||||
tempfile:
|
||||
state: directory
|
||||
suffix: .django_manage
|
||||
register: tmp_django_root
|
||||
|
||||
- name: Install required library
|
||||
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_manage_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_manage:
|
||||
project_path: "{{ tmp_django_root.path }}/startproj/test_django_manage_1"
|
||||
command: check
|
||||
virtualenv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Check simple_project
|
||||
community.general.django_manage:
|
||||
project_path: "{{ tmp_django_root.path }}/simple_project/p1"
|
||||
command: check
|
||||
virtualenv: "{{ tmp_django_root.path }}/venv"
|
||||
|
||||
- name: Check custom project
|
||||
community.general.django_manage:
|
||||
project_path: "{{ tmp_django_root.path }}/1045-single-app-project/single_app_project"
|
||||
pythonpath: "{{ tmp_django_root.path }}/1045-single-app-project/"
|
||||
command: check
|
||||
virtualenv: "{{ tmp_django_root.path }}/venv"
|
|
@ -376,5 +376,18 @@ plugins/modules/system/xfconf.py validate-modules:parameter-state-invalid-choice
|
|||
plugins/modules/system/xfconf.py validate-modules:return-syntax-error
|
||||
plugins/modules/web_infrastructure/jenkins_plugin.py use-argspec-type-path
|
||||
plugins/modules/web_infrastructure/rundeck_acl_policy.py pylint:blacklisted-name
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py pep8:E302 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py pep8:E305 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py shebang # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.7 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/urls.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/urls.py future-import-boilerplate # django generated code
|
||||
tests/utils/shippable/check_matrix.py replace-urlopen
|
||||
tests/utils/shippable/timing.py shebang
|
||||
|
|
|
@ -376,5 +376,18 @@ plugins/modules/system/xfconf.py validate-modules:parameter-state-invalid-choice
|
|||
plugins/modules/system/xfconf.py validate-modules:return-syntax-error
|
||||
plugins/modules/web_infrastructure/jenkins_plugin.py use-argspec-type-path
|
||||
plugins/modules/web_infrastructure/rundeck_acl_policy.py pylint:blacklisted-name
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py pep8:E302 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py pep8:E305 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py shebang # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.7 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/urls.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/urls.py future-import-boilerplate # django generated code
|
||||
tests/utils/shippable/check_matrix.py replace-urlopen
|
||||
tests/utils/shippable/timing.py shebang
|
||||
|
|
|
@ -324,5 +324,18 @@ plugins/modules/web_infrastructure/jenkins_plugin.py use-argspec-type-path
|
|||
plugins/modules/web_infrastructure/nginx_status_facts.py validate-modules:deprecation-mismatch
|
||||
plugins/modules/web_infrastructure/nginx_status_facts.py validate-modules:invalid-documentation
|
||||
plugins/modules/web_infrastructure/rundeck_acl_policy.py pylint:blacklisted-name
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py pep8:E302 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py pep8:E305 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/1045-single-app-project/single_app_project/manage.py shebang # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.7 # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py future-import-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/urls.py metaclass-boilerplate # django generated code
|
||||
tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/urls.py future-import-boilerplate # django generated code
|
||||
tests/utils/shippable/check_matrix.py replace-urlopen
|
||||
tests/utils/shippable/timing.py shebang
|
||||
|
|
Loading…
Reference in a new issue