add tests system, via tox

This commit is contained in:
Thomas NOËL 2019-07-15 18:03:43 +02:00
parent 7897daaf49
commit 2646ab4ee7
12 changed files with 83 additions and 9 deletions

16
Jenkinsfile vendored
View File

@ -3,6 +3,22 @@
pipeline {
agent any
stages {
stage('Unit Tests') {
steps {
sh 'tox -rv'
}
post {
always {
script {
utils = new Utils()
utils.publish_coverage('coverage.xml')
utils.publish_coverage_native('index.html')
utils.publish_pylint('pylint.out')
}
junit '*_results.xml'
}
}
}
stage('Packaging') {
steps {
script {

4
README
View File

@ -4,10 +4,8 @@ Passerelle connector to openADS
Installation
------------
- create a symbolik link from this module to the passerelle 'apps' directory
- add to Passerelle installed apps settings:
INSTALLED_APPS += ('passerelle.apps.atreal_openads',)
INSTALLED_APPS += ('atreal_openads',)
Usage

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
from django.db import migrations, models
import passerelle.apps.atreal_openads.models
import atreal_openads.models
class Migration(migrations.Migration):
@ -43,7 +43,7 @@ class Migration(migrations.Migration):
('file_hash', models.CharField(blank=True, default=b'', max_length=100)),
('orig_filename', models.CharField(blank=True, default=b'', max_length=100)),
('content_type', models.CharField(blank=True, default=b'', max_length=100)),
('upload_file', models.FileField(null=True, upload_to=passerelle.apps.atreal_openads.models.get_upload_path)),
('upload_file', models.FileField(null=True, upload_to=atreal_openads.models.get_upload_path)),
('upload_status', models.CharField(blank=True, default=b'', max_length=10)),
('upload_msg', models.CharField(blank=True, default=b'', max_length=255)),
('last_update_datetime', models.DateTimeField(auto_now=True)),

5
debian/control vendored
View File

@ -1,5 +1,5 @@
Source: passerelle-atreal-openads
Maintainer: Frederic Peters <fpeters@entrouvert.com>
Maintainer: Michael Bideau <mbideau+publik@atreal.fr>
Section: python
Priority: optional
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 9), python-django
@ -7,6 +7,7 @@ Standards-Version: 3.9.1
Package: python-passerelle-atreal-openads
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}
Depends: ${misc:Depends}, ${python:Depends},
python-magic
Description: Passerelle connector to openADS.API
.

View File

@ -40,6 +40,9 @@ setup(
packages=find_packages(),
cmdclass={
'sdist': eo_sdist,
}
},
install_requires=[
'python-magic',
],
)

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

27
tests/settings.py Normal file
View File

@ -0,0 +1,27 @@
import os
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
# include app
INSTALLED_APPS += (
'atreal_openads',
)
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
'dummy': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
}
}
DATABASES = {
'default': {
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'),
'TEST': {
'NAME': 'passerelle-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:63],
},
}
}

View File

@ -19,7 +19,7 @@ from django.http.request import HttpRequest, QueryDict
from django.http.response import JsonResponse
from django.core.files import File
from passerelle.apps.atreal_openads.models import AtrealOpenads, ForwardFile
from atreal_openads.models import AtrealOpenads, ForwardFile
from passerelle.utils.jsonresponse import APIError
from passerelle.base.models import Job

29
tox.ini Normal file
View File

@ -0,0 +1,29 @@
[tox]
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle-atreal-openads/{env:BRANCH_NAME:}
envlist = django111-pg
[testenv]
usedevelop = True
basepython = python2
setenv =
DJANGO_SETTINGS_MODULE=passerelle.settings
PASSERELLE_SETTINGS_FILE=tests/settings.py
BRANCH_NAME={env:BRANCH_NAME:}
fast: FAST=--nomigrations
sqlite: DB_ENGINE=django.db.backends.sqlite3
pg: DB_ENGINE=django.db.backends.postgresql_psycopg2
deps =
django112: django>=1.11,<1.12
http://git.entrouvert.org/passerelle.git/snapshot/passerelle-master.tar.gz
psycopg2-binary
pytest-cov
pytest-django<3.4.6
pytest
WebTest
mock
httmock
pylint<1.8
pylint-django<0.8.1
django-webtest<1.9.3
commands =
django111: py.test {posargs: --junitxml=test_{envname}_results.xml tests/}