2013-04-16 00:19:59 +02:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
Fabric file for OpenSlides developers.
|
|
|
|
|
|
|
|
|
|
:copyright: 2011–2013 by OpenSlides team, see AUTHORS.
|
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
2013-04-24 07:36:37 +02:00
|
|
|
|
import sys
|
2013-04-16 00:19:59 +02:00
|
|
|
|
import webbrowser
|
|
|
|
|
|
|
|
|
|
from fabric.api import local
|
|
|
|
|
from fabric.contrib import django
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test(module='tests'):
|
|
|
|
|
"""
|
2013-04-16 14:37:27 +02:00
|
|
|
|
Runs all unit tests for OpenSlides using coverage.
|
|
|
|
|
|
|
|
|
|
The settings file in the tests directory is used, therefor the
|
|
|
|
|
environment variable DJANGO_SETTINGS_MODULE is set to 'tests.settings'.
|
2013-04-16 00:19:59 +02:00
|
|
|
|
"""
|
|
|
|
|
django.settings_module('tests.settings')
|
2013-09-08 14:30:26 +02:00
|
|
|
|
local('coverage run ./manage.py django test %s' % module)
|
2013-04-16 00:19:59 +02:00
|
|
|
|
|
|
|
|
|
|
2013-04-16 14:37:27 +02:00
|
|
|
|
def coverage_report_plain():
|
|
|
|
|
"""
|
|
|
|
|
Runs all tests and prints the coverage report.
|
|
|
|
|
"""
|
|
|
|
|
test()
|
2013-10-30 17:48:09 +01:00
|
|
|
|
local('coverage report -m --fail-under=73')
|
2013-04-16 14:37:27 +02:00
|
|
|
|
|
|
|
|
|
|
2013-04-16 00:19:59 +02:00
|
|
|
|
def coverage():
|
|
|
|
|
"""
|
2013-04-16 14:37:27 +02:00
|
|
|
|
Runs all tests and builds the coverage html files.
|
|
|
|
|
|
|
|
|
|
The index of these files is opened in the webbrowser in the end.
|
2013-04-16 00:19:59 +02:00
|
|
|
|
"""
|
|
|
|
|
test()
|
|
|
|
|
local('coverage html')
|
|
|
|
|
webbrowser.open(os.path.join(os.path.dirname(__file__), 'htmlcov', 'index.html'))
|
|
|
|
|
|
|
|
|
|
|
2013-09-25 10:01:01 +02:00
|
|
|
|
def check():
|
2013-04-16 00:19:59 +02:00
|
|
|
|
"""
|
|
|
|
|
Checks for PEP 8 errors in openslides and in tests.
|
|
|
|
|
"""
|
2013-09-25 10:01:01 +02:00
|
|
|
|
local('flake8 --max-line-length=150 --statistics openslides')
|
|
|
|
|
local('flake8 --max-line-length=150 --statistics tests')
|
2013-04-16 00:19:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prepare_commit():
|
|
|
|
|
"""
|
2013-04-22 22:31:58 +02:00
|
|
|
|
Does everything that should be done before a commit.
|
2013-04-16 14:37:27 +02:00
|
|
|
|
|
|
|
|
|
At the moment it is running the tests and check for PEP 8 errors.
|
2013-04-16 00:19:59 +02:00
|
|
|
|
"""
|
2013-04-16 14:37:27 +02:00
|
|
|
|
test()
|
2013-09-25 10:01:01 +02:00
|
|
|
|
check()
|
2013-04-16 00:19:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def travis_ci():
|
|
|
|
|
"""
|
|
|
|
|
Command that is run by Travis CI.
|
|
|
|
|
"""
|
2013-04-16 14:37:27 +02:00
|
|
|
|
coverage_report_plain()
|
2013-09-25 10:01:01 +02:00
|
|
|
|
check()
|
2013-04-24 07:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_script(script):
|
|
|
|
|
"""
|
|
|
|
|
Run a script with the development version of OpenSlides.
|
|
|
|
|
|
|
|
|
|
You can find some usefull scripts in extras/scrips/ in the OpenSlides repo.
|
|
|
|
|
"""
|
|
|
|
|
os.environ['PYTHONPATH'] = os.path.join(os.path.dirname(__file__))
|
|
|
|
|
os.system("python " + script)
|