Skip to content
Snippets Groups Projects
Commit 478b429a authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Testing app in CI

parent 101e0033
Branches
Tags
No related merge requests found
image: docker:latest
stages:
- test
test35:
stage: test
image: python:3.5
script:
- pip install -r requirements.txt
- coverage run --source='basetheme_bootstrap' runtests.py && coverage report -m
test36:
stage: test
image: python:3.6
script:
- pip install -r requirements.txt
- coverage run --source='basetheme_bootstrap' runtests.py && coverage report -m
test37:
stage: test
image: python:3.7
script:
- pip install -r requirements.txt
- coverage run --source='basetheme_bootstrap' runtests.py && coverage report -m
django
django-crispy-forms
coverage
\ No newline at end of file
#!/usr/bin/env python3
import os
import sys
import django
from django.conf import settings
from django.core.cache import cache
from django.test.utils import get_runner
def runtests():
test_dir = os.path.dirname(__file__)
sys.path.insert(0, test_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
# failures = test_runner.run_tests(["basetheme_bootstrap.tests.SignUpTestsUserPrefDown"], verbosity=1, interactive=True)
failures = test_runner.run_tests([], verbosity=1, interactive=True)
if bool(failures):
print(failures)
sys.exit(1)
# def run_all_tests():
# os.environ['BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_ENABLED'] = str(True)
# runtests()
# os.environ['BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_ENABLED'] = str(False)
# runtests()
#
# sys.exit(0)
if __name__ == '__main__':
runtests()
from django.apps import AppConfig
class TestApp1Config(AppConfig):
name = 'test_app_1'
# Generated by Django 2.1.7 on 2019-03-26 16:52
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='MyUserPreferences',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('hide_help', models.BooleanField(default=False, help_text='hide_help__help_text', verbose_name='hide_help__verbose_name')),
('a_time_field', models.TimeField(blank=True, help_text='a_time_field_UTC__help_text', null=True, verbose_name='a_time_field__verbose_name')),
('user', models.ForeignKey(blank=True, help_text='Leave blank for default user', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_preferences', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
from basetheme_bootstrap import user_preferences
class MyUserPreferences(user_preferences.UserPreferencesAbstractModel, models.Model):
hide_help = models.BooleanField(
verbose_name=_("hide_help__verbose_name"),
help_text=_("hide_help__help_text"),
default=False,
)
a_time_field = models.TimeField(
verbose_name=_("a_time_field__verbose_name"),
help_text=_("a_time_field_%(tz)s__help_text") % dict(tz=settings.TIME_ZONE),
null=True,
blank=True,
)
"""
Django settings for test_proj project.
Generated by 'django-admin startproject' using Django 2.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '110qzc77+t2o8cp&ijk!mpxb=*)7v*!xs2pj^t5=#=n*seo$i!'
# 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',
'crispy_forms',
'basetheme_bootstrap',
'test_app_1',
]
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 = 'tests.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',
'basetheme_bootstrap.context_processors.processors',
],
},
},
]
WSGI_APPLICATION = 'tests.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.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/2.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/2.1/howto/static-files/
STATIC_URL = '/static/'
################################################################################
# django-crispy-forms
################################################################################
CRISPY_TEMPLATE_PACK = 'bootstrap4'
################################################################################
# basetheme_bootstrap
################################################################################
BASETHEME_BOOTSTRAP_TEMPLATE_LOCATION_PROJECT = "test_app_1"
BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_ENABLED = True
BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_LOCATION_APP = "test_app_1"
BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_NAME = "MyUserPreferences"
################################################################################
from django.http import HttpResponse
from django.urls import path, include
def blabla(request):
return HttpResponse("ee")
urlpatterns = [
path('', blabla, name='home'),
path('', include('basetheme_bootstrap.urls')),
]
"""
WSGI config for time_tracking project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
application = get_wsgi_application()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment