From 2c374d687fbfcaadf99509ed632f168d602859cb Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Fri, 13 Apr 2018 15:59:33 -0700 Subject: [VVP] adding config for test coverage report modifed tox, pom, and tests to create coverage report Change-Id: I98321c3d5c205622a3b4f5662566934f323ba70f Issue-ID: VVP-56 Signed-off-by: stark, steven --- .../engagementmanager/tests/test_expanded_eng.py | 2 +- django/vvp/settings/tox_settings.py | 1 + mvn-phase-script.sh | 60 ++++++++++++++++++++++ pom.xml | 39 ++++++++++++++ tox.ini | 4 +- 5 files changed, 104 insertions(+), 2 deletions(-) create mode 100755 mvn-phase-script.sh diff --git a/django/engagementmanager/tests/test_expanded_eng.py b/django/engagementmanager/tests/test_expanded_eng.py index de2a622..82b1616 100644 --- a/django/engagementmanager/tests/test_expanded_eng.py +++ b/django/engagementmanager/tests/test_expanded_eng.py @@ -323,7 +323,7 @@ class testGetExpandedEngsAndSearch(TestBaseEntity): urlStr = self.urlPrefix + 'vf' + str(vf.uuid) + '/vfcs/' vfc_of_x_response = self.c.get( urlStr, **{'HTTP_AUTHORIZATION': "token " + self.token}) - vfc_list = json.loads(vfc_of_x_response.content) + vfc_list = json.loads(vfc_of_x_response.content) or {} for vfc in vfc_list: if (vfc['name'] == self.random_keyword): bool_flag = True diff --git a/django/vvp/settings/tox_settings.py b/django/vvp/settings/tox_settings.py index ff1aabd..e562bc3 100644 --- a/django/vvp/settings/tox_settings.py +++ b/django/vvp/settings/tox_settings.py @@ -99,6 +99,7 @@ INSTALLED_APPS = [ 'rest_framework', 'engagementmanager.apps.EngagementmanagerConfig', 'validationmanager.apps.ValidationmanagerConfig', + 'django_jenkins', ] MIDDLEWARE_CLASSES = [ diff --git a/mvn-phase-script.sh b/mvn-phase-script.sh new file mode 100755 index 0000000..77979dc --- /dev/null +++ b/mvn-phase-script.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# ================================================================================ +# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. + +set -ex + + +echo "running script: [$0] for module [$1] at stage [$2]" + +MVN_PROJECT_MODULEID="$1" +MVN_PHASE="$2" +PROJECT_ROOT=$(dirname $0) + +run_tox_test () { + CURDIR=$(pwd) + TOXINIS=. + for TOXINI in "${TOXINIS[@]}"; do + DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev) + cd "${CURDIR}/${DIR}" + rm -rf ./venv-tox ./.tox + virtualenv ./venv-tox + source ./venv-tox/bin/activate + pip install --upgrade pip + pip install --upgrade tox argparse + pip freeze + tox + deactivate + rm -rf ./venv-tox ./.tox + done +} + +# Customize the section below for each project +case $MVN_PHASE in +test) + echo "==> test phase script" + run_tox_test + ;; +*) + echo "==> unprocessed phase" + ;; +esac + + + diff --git a/pom.xml b/pom.xml index 4c8f4e9..7f678af 100644 --- a/pom.xml +++ b/pom.xml @@ -25,9 +25,28 @@ ${project.version}-latest nexus3.onap.org:10001 nexus3.onap.org:10003 + + UTF-8 + . + django/reports/coverage.xml + py + python + django/**.py + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + ${session.executionRootDirectory}/mvn-phase-script.sh + + + + org.sonatype.plugins @@ -97,6 +116,26 @@ + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + test script + test + + exec + + + + __ + test + + + + + diff --git a/tox.ini b/tox.ini index f8cb41b..c632928 100644 --- a/tox.ini +++ b/tox.ini @@ -38,8 +38,10 @@ setenv = [testenv:py36-django1-10-6] basepython = python3.6 deps = -r{toxinidir}/django/requirements.txt + django-jenkins + coverage commands = python --version - django-admin.py test + python {toxinidir}/django/manage.py jenkins --enable-coverage [testenv:style] basepython = python3 -- cgit