diff --git a/Jenkinsfile b/Jenkinsfile index 8f934df..d6e7b7b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,20 @@ pipeline { agent any + options { + disableConcurrentBuilds() + } stages { + stage('Unit Tests') { + steps { + sh 'tox -rv' + } + post { + always { + mergeJunitResults() + } + } + } stage('Packaging') { steps { script { diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..71d4f83 --- /dev/null +++ b/tests/settings.py @@ -0,0 +1,14 @@ +import os + + +INSTALLED_APPS += ('combo_plugin_nanterre',) + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'TEST': { + 'NAME': 'combo-plugin-nanterre-test-%s' + % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:40], + }, + } +} diff --git a/tests/test_nanterre.py b/tests/test_nanterre.py new file mode 100644 index 0000000..3c56768 --- /dev/null +++ b/tests/test_nanterre.py @@ -0,0 +1,15 @@ +import django_webtest +import pytest + + +@pytest.fixture +def app(request, db): + wtm = django_webtest.WebTestMixin() + wtm._patch_settings() + yield django_webtest.DjangoTestApp() + wtm._unpatch_settings() + + +def test_url(app): + resp = app.get('/_plugin/nanterre/saga-retour-asynchrone/') + assert resp.json == {'err': 1} diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..30c88ac --- /dev/null +++ b/tox.ini @@ -0,0 +1,31 @@ +[tox] +envlist = py3-black-pytest-coverage +toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/combo-plugin-nanterre/{env:BRANCH_NAME:} + +[testenv] +usedevelop = + coverage: True + nocoverage: False +setenv = + DJANGO_SETTINGS_MODULE=combo.settings + COMBO_SETTINGS_FILE=tests/settings.py + DB_ENGINE=django.db.backends.postgresql_psycopg2 + SETUPTOOLS_USE_DISTUTILS=stdlib + coverage: COVERAGE=--cov-report xml --cov-report html --cov=combo_plugin_nanterre/ + pytest: PYTEST=--junitxml=junit-{envname}.xml +deps = + pytest + pytest-cov + pytest-django + WebTest + django-webtest + psycopg2-binary + psycopg2 + django-ratelimit<3 + django>=2.2,<2.3 + git+https://git.entrouvert.org/debian/django-ckeditor.git + git+https://git.entrouvert.org/combo.git + black: pre-commit +commands = + pytest: py.test {posargs: {env:PYTEST:} {env:COVERAGE:} tests/} + black: pre-commit run black --all-files --show-diff-on-failure