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
|
|
|
|
|
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')
|
|
|
|
|
local('coverage run ./manage.py test %s' % module)
|
|
|
|
|
|
|
|
|
|
|
2013-04-16 14:37:27 +02:00
|
|
|
|
def coverage_report_plain():
|
|
|
|
|
"""
|
|
|
|
|
Runs all tests and prints the coverage report.
|
|
|
|
|
"""
|
|
|
|
|
test()
|
|
|
|
|
local('coverage report -m')
|
|
|
|
|
|
|
|
|
|
|
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'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pep8():
|
|
|
|
|
"""
|
|
|
|
|
Checks for PEP 8 errors in openslides and in tests.
|
|
|
|
|
"""
|
|
|
|
|
local('pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides')
|
|
|
|
|
local('pep8 --max-line-length=150 --statistics tests')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prepare_commit():
|
|
|
|
|
"""
|
2013-04-16 14:37:27 +02:00
|
|
|
|
Does everything before a commit should be done.
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
pep8()
|
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-04-16 00:19:59 +02:00
|
|
|
|
pep8()
|