upgrade ci infra (#50115)

This commit is contained in:
Emmanuel Cazenave 2021-01-13 17:09:48 +01:00
parent cdfbe3e151
commit 1637c27574
4 changed files with 80 additions and 0 deletions

13
Jenkinsfile vendored
View File

@ -2,7 +2,20 @@
pipeline {
agent any
options {
disableConcurrentBuilds()
}
stages {
stage('Unit Tests') {
steps {
sh 'tox -rv'
}
post {
always {
mergeJunitResults()
}
}
}
stage('Packaging') {
steps {
script {

14
tests/settings.py Normal file
View File

@ -0,0 +1,14 @@
import os
INSTALLED_APPS += ('grandlyon_cartads_cs',)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'TEST': {
'NAME': 'passerelle-grandlyon-cartads-cs-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:40],
}
}
}

34
tests/test_connector.py Normal file
View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
import django_webtest
import pytest
from grandlyon_cartads_cs.models import GLCartaDSCS
from passerelle.base.models import ApiUser, AccessRight
@pytest.fixture
def app(request):
wtm = django_webtest.WebTestMixin()
wtm._patch_settings()
cache.clear()
yield django_webtest.DjangoTestApp()
wtm._unpatch_settings()
@pytest.fixture
def connector(db):
connector = GLCartaDSCS.objects.create(
slug='test', token_url='https://whatever')
api = ApiUser.objects.create(username='all', keytype='', key='')
obj_type = ContentType.objects.get_for_model(connector)
AccessRight.objects.create(
codename='can_access', apiuser=api,
resource_type=obj_type, resource_pk=connector.pk)
def test_dummny(app, connector):
assert True

19
tox.ini Normal file
View File

@ -0,0 +1,19 @@
[tox]
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle-grandlyon-cartads-cs/{env:BRANCH_NAME:}
envlist = py3-{django111,django22}
[testenv]
usedevelop = True
setenv =
DJANGO_SETTINGS_MODULE=passerelle.settings
PASSERELLE_SETTINGS_FILE=tests/settings.py
deps =
django111: django>=1.11,<1.12
django22: django>=2.2,<2.3
git+https://git.entrouvert.org/passerelle.git
django-webtest
psycopg2-binary
pytest
pytest-django
commands =
py.test {posargs: --junitxml=junit-{envname}.xml tests/}