murano-dashbord python3 fix and use standard cover tox env
Change-Id: I1d68ca7cbe325425cd1c05ff3101f19d3cb50b0a
This commit is contained in:
parent
7e2413c322
commit
caaa9ea88d
|
@ -20,6 +20,7 @@ Django==1.11
|
|||
django-appconf==1.0.2
|
||||
django-babel==0.6.2
|
||||
django-compressor==2.0
|
||||
django-floppyforms==1.7.0
|
||||
django-formtools==2.0
|
||||
django-nose==1.4.4
|
||||
django-pyscss==2.0.2
|
||||
|
|
|
@ -35,7 +35,7 @@ import selenium.webdriver.common.by as by
|
|||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support import ui
|
||||
|
||||
import config.config as cfg
|
||||
from muranodashboard.tests.functional.config import config as cfg
|
||||
from muranodashboard.tests.functional import consts
|
||||
from muranodashboard.tests.functional import utils
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
import multiprocessing
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import SimpleHTTPServer
|
||||
import SocketServer
|
||||
import socketserver
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
@ -2765,10 +2765,10 @@ class TestSuiteRepository(base.PackageTestCase):
|
|||
self.serve_dir = tempfile.mkdtemp(suffix="repo")
|
||||
|
||||
def serve_function():
|
||||
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
pass
|
||||
os.chdir(self.serve_dir)
|
||||
httpd = SocketServer.TCPServer(
|
||||
httpd = socketserver.TCPServer(
|
||||
("0.0.0.0", 8099),
|
||||
Handler, bind_and_activate=False)
|
||||
httpd.allow_reuse_address = True
|
||||
|
|
|
@ -19,7 +19,7 @@ import zipfile
|
|||
from oslo_log import log
|
||||
from selenium.webdriver.support import wait
|
||||
|
||||
import config.config as cfg
|
||||
from muranodashboard.tests.functional.config import config as cfg
|
||||
from muranodashboard.tests.functional import consts
|
||||
|
||||
log = log.getLogger(__name__).logger
|
||||
|
|
|
@ -12,6 +12,7 @@ pytz>=2013.6 # MIT
|
|||
PyYAML>=3.12 # MIT
|
||||
yaql>=1.1.3 # Apache 2.0 License
|
||||
castellan>=0.18.0 # Apache-2.0
|
||||
django-floppyforms>=1.7.0,<2 # BSD
|
||||
|
||||
oslo.log>=3.36.0 # Apache-2.0
|
||||
semantic-version>=2.3.1 # BSD
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2016: Mirantis Inc.
|
||||
# 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.
|
||||
|
||||
set -x
|
||||
|
||||
ALLOWED_EXTRA_MISSING=4
|
||||
|
||||
show_diff () {
|
||||
head -1 $1
|
||||
diff -U 0 $1 $2 | sed 1,2d
|
||||
}
|
||||
|
||||
# Stash uncommitted changes, checkout master and save coverage report
|
||||
uncommitted=$(git status --porcelain | grep -v "^??")
|
||||
[[ -n $uncommitted ]] && git stash > /dev/null
|
||||
git checkout HEAD^
|
||||
|
||||
baseline_report=$(mktemp -t murano_dashboard_coverageXXXXXXX)
|
||||
find . -type f -name "*.pyc" -delete
|
||||
echo $(which manage.py)
|
||||
python manage.py test muranodashboard \
|
||||
--settings=muranodashboard.tests.settings \
|
||||
--cover-erase --with-coverage --cover-html --cover-inclusive
|
||||
coverage report > $baseline_report
|
||||
baseline_missing=$(awk 'END { print $3 }' $baseline_report)
|
||||
|
||||
# Checkout back and unstash uncommitted changes (if any)
|
||||
git checkout -
|
||||
[[ -n $uncommitted ]] && git stash pop > /dev/null
|
||||
|
||||
# Generate and save coverage report
|
||||
current_report=$(mktemp -t murano_dashboard_coverageXXXXXXX)
|
||||
find . -type f -name "*.pyc" -delete
|
||||
echo $(which manage.py)
|
||||
python manage.py test muranodashboard \
|
||||
--settings=muranodashboard.tests.settings \
|
||||
--cover-erase --with-coverage --cover-html --cover-inclusive
|
||||
coverage report > $current_report
|
||||
current_missing=$(awk 'END { print $3 }' $current_report)
|
||||
|
||||
baseline_percentage=$(awk 'END { print $4 }' $baseline_report)
|
||||
current_percentage=$(awk 'END { print $4 }' $current_report)
|
||||
# Show coverage details
|
||||
allowed_missing=$((baseline_missing+ALLOWED_EXTRA_MISSING))
|
||||
|
||||
echo "Baseline report:"
|
||||
echo "$(cat ${baseline_report})"
|
||||
echo "Proposed change report:"
|
||||
echo "$(cat ${current_report})"
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Allowed to introduce missing lines : ${ALLOWED_EXTRA_MISSING}"
|
||||
echo "Missing lines in master : ${baseline_missing}"
|
||||
echo "Missing lines in proposed change : ${current_missing}"
|
||||
echo "Current percentage : ${baseline_percentage}"
|
||||
echo "Proposed change percentage : ${current_percentage}"
|
||||
|
||||
if [ $allowed_missing -gt $current_missing ];
|
||||
then
|
||||
if [ $baseline_missing -lt $current_missing ];
|
||||
then
|
||||
show_diff $baseline_report $current_report
|
||||
echo "I believe you can cover all your code with 100% coverage!"
|
||||
else
|
||||
echo "Thank you! You are awesome! Keep writing unit tests! :)"
|
||||
fi
|
||||
exit_code=0
|
||||
else
|
||||
show_diff $baseline_report $current_report
|
||||
echo "Please write more unit tests, we should keep our test coverage :( "
|
||||
exit_code=1
|
||||
fi
|
||||
|
||||
rm $baseline_report $current_report
|
||||
set +x
|
||||
exit $exit_code
|
7
tox.ini
7
tox.ini
|
@ -36,7 +36,12 @@ commands = {posargs}
|
|||
|
||||
[testenv:cover]
|
||||
basepython = python3
|
||||
commands = {toxinidir}/tools/cover.sh {posargs}
|
||||
commands =
|
||||
coverage erase
|
||||
coverage run -a {toxinidir}/manage.py test muranodashboard --settings=muranodashboard.tests.settings
|
||||
coverage html -d cover
|
||||
coverage xml -o cover/coverage.xml
|
||||
coverage report
|
||||
|
||||
[testenv:pyflakes]
|
||||
deps = flake8
|
||||
|
|
Loading…
Reference in New Issue