add tests
This commit is contained in:
parent
cb16529ea0
commit
8ecab8f6ed
|
@ -0,0 +1,42 @@
|
|||
@Library('eo-jenkins-lib@main') import eo.Utils
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
}
|
||||
stages {
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh 'tox -rv'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
mergeJunitResults()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Packaging') {
|
||||
steps {
|
||||
script {
|
||||
if (env.JOB_NAME == 'combo-plugin-imio-townstreet' && env.GIT_BRANCH == 'origin/main') {
|
||||
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder combo-plugin-imio-townstreet'
|
||||
} else if (env.GIT_BRANCH.startsWith('hotfix/')) {
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder --branch ${env.GIT_BRANCH} --hotfix combo-plugin-imio-townstreet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
utils = new Utils()
|
||||
utils.mail_notify(currentBuild, env, 'ci+jenkins-combo-plugin-imio-townstreet@entrouvert.org')
|
||||
}
|
||||
}
|
||||
success {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import pytest
|
||||
import django_webtest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(request, db):
|
||||
wtm = django_webtest.WebTestMixin()
|
||||
wtm._patch_settings()
|
||||
request.addfinalizer(wtm._unpatch_settings)
|
||||
return django_webtest.DjangoTestApp()
|
|
@ -0,0 +1,13 @@
|
|||
import os
|
||||
|
||||
INSTALLED_APPS += ('combo_plugin_imio_townstreet',)
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'TEST': {
|
||||
'NAME': 'combo-plugin-imio-townstreet-test-%s'
|
||||
% os.environ.get("BRANCH_NAME", "").replace('/', '-')[:40],
|
||||
},
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from combo.data.models import Page
|
||||
|
||||
from combo_plugin_imio_townstreet.models import TownstreetButton
|
||||
|
||||
|
||||
def test_button(app):
|
||||
page = Page(title='One', slug='index')
|
||||
page.save()
|
||||
button = TownstreetButton(page=page, order=0, placeholder='content')
|
||||
button.save()
|
||||
resp = app.get('/', status=200)
|
||||
assert 'Signaler un problème sur l’espace public' in resp
|
|
@ -0,0 +1,31 @@
|
|||
[tox]
|
||||
envlist = py3-black-junit-coverage
|
||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/combo-plugin-imio-townstreet/{env:BRANCH_NAME:}
|
||||
|
||||
[testenv]
|
||||
usedevelop =
|
||||
coverage: True
|
||||
nocoverage: False
|
||||
setenv =
|
||||
DJANGO_SETTINGS_MODULE=combo.settings
|
||||
DB_ENGINE=django.db.backends.postgresql_psycopg2
|
||||
SETUPTOOLS_USE_DISTUTILS=stdlib
|
||||
COMBO_SETTINGS_FILE=tests/settings.py
|
||||
coverage: COVERAGE=--cov-report xml --cov-report html --cov=combo_plugin_imio-townstreet/
|
||||
junit: JUNIT=--junitxml=junit-{envname}.xml
|
||||
deps =
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-django
|
||||
django-webtest<1.9.3
|
||||
WebTest
|
||||
mock<4
|
||||
psycopg2-binary
|
||||
psycopg2
|
||||
django>=1.11,<2.3
|
||||
https://git.entrouvert.org/debian/django-ckeditor.git/snapshot/django-ckeditor-main.tar.gz
|
||||
https://git.entrouvert.org/combo.git/snapshot/combo-main.tar.gz
|
||||
pre-commit
|
||||
commands =
|
||||
py.test {posargs: {env:JUNIT:} {env:COVERAGE:} tests/}
|
||||
black: pre-commit run black --all-files --show-diff-on-failure
|
Loading…
Reference in New Issue