Simplify test runner by adding a new option '--mayan-apps' that
automatically tests all Mayan apps that report to have tests. Change the app flag that indicates when an app has test from 'test' to the more explicit 'has_test'. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -21,7 +21,7 @@ test:mysql:
|
||||
- pip install mysql-python
|
||||
- apt-get install -qq mysql-client
|
||||
- mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e "set global character_set_server=utf8mb4;"
|
||||
- coverage run manage.py test --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
|
||||
- coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
|
||||
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
||||
tags:
|
||||
- mysql
|
||||
@@ -30,12 +30,12 @@ test:postgres:
|
||||
- apt-get install -qq libpq-dev
|
||||
- pip install -r requirements/testing.txt
|
||||
- pip install psycopg2
|
||||
- coverage run manage.py test --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
|
||||
- coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
|
||||
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
||||
tags:
|
||||
- postgres
|
||||
test:sqlite:
|
||||
script:
|
||||
- pip install -r requirements/testing.txt
|
||||
- coverage run manage.py test --settings=mayan.settings.testing.gitlab-ci --nomigrations
|
||||
- coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci --nomigrations
|
||||
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
||||
|
||||
@@ -17,9 +17,9 @@ before_script:
|
||||
- mysql -e 'create database mayan_edms;'
|
||||
- psql -c 'create database mayan_edms;' -U postgres
|
||||
script:
|
||||
- if [[ $DB == mysql ]]; then coverage run manage.py test --settings=mayan.settings.testing.travis.db_mysql --nomigrations; fi
|
||||
- if [[ $DB == postgres ]]; then coverage run manage.py test --settings=mayan.settings.testing.travis.db_postgres --nomigrations; fi
|
||||
- if [[ $DB == sqlite ]]; then coverage run manage.py test --settings=mayan.settings.testing.base --nomigrations; fi
|
||||
- if [[ $DB == mysql ]]; then coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.travis.db_mysql --nomigrations; fi
|
||||
- if [[ $DB == postgres ]]; then coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.travis.db_postgres --nomigrations; fi
|
||||
- if [[ $DB == sqlite ]]; then coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.base --nomigrations; fi
|
||||
after_success:
|
||||
- coveralls
|
||||
branches:
|
||||
|
||||
5
Makefile
5
Makefile
@@ -7,7 +7,7 @@ help:
|
||||
@echo "clean-pyc - Remove Python artifacts."
|
||||
@echo "clean - Remove Python and build artifacts."
|
||||
|
||||
@echo "test - Run all tests."
|
||||
@echo "test-all - Run all tests."
|
||||
@echo "test MODULE=<python module name> - Run tests for a single App, module or test class."
|
||||
@echo "docs_serve - Run the livehtml documentation generator."
|
||||
|
||||
@@ -56,6 +56,9 @@ clean-pyc:
|
||||
test:
|
||||
./manage.py test $(MODULE) --settings=mayan.settings.testing --nomigrations
|
||||
|
||||
test-all:
|
||||
./manage.py test --mayan-apps --settings=mayan.settings.testing --nomigrations
|
||||
|
||||
|
||||
# Documentation
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ from .links import link_acl_create, link_acl_delete, link_acl_permissions
|
||||
|
||||
|
||||
class ACLsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'acls'
|
||||
test = True
|
||||
verbose_name = _('ACLs')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -12,8 +12,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AuthenticationApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'authentication'
|
||||
test = True
|
||||
verbose_name = _('Authentication')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -28,8 +28,8 @@ from .permissions import (
|
||||
|
||||
|
||||
class CabinetsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'cabinets'
|
||||
test = True
|
||||
verbose_name = _('Cabinets')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -30,8 +30,8 @@ from .tasks import task_check_expired_check_outs # NOQA
|
||||
|
||||
|
||||
class CheckoutsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'checkouts'
|
||||
test = True
|
||||
verbose_name = _('Checkouts')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -71,8 +71,8 @@ class MayanAppConfig(apps.AppConfig):
|
||||
|
||||
class CommonApp(MayanAppConfig):
|
||||
app_url = ''
|
||||
has_tests = True
|
||||
name = 'common'
|
||||
test = True
|
||||
verbose_name = _('Common')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -1,41 +1,30 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from django import apps
|
||||
from django.conf import settings
|
||||
from django.test.runner import DiscoverRunner
|
||||
|
||||
|
||||
class MayanTestRunner(DiscoverRunner):
|
||||
@classmethod
|
||||
def add_arguments(cls, parser):
|
||||
DiscoverRunner.add_arguments(parser)
|
||||
parser.add_argument(
|
||||
'--mayan-apps', action='store_true', default=False,
|
||||
dest='mayan_apps',
|
||||
help='Test all Mayan apps that report to have tests.'
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.mayan_apps = kwargs.pop('mayan_apps')
|
||||
super(MayanTestRunner, self).__init__(*args, **kwargs)
|
||||
|
||||
def build_suite(self, *args, **kwargs):
|
||||
self.top_level = os.path.join(settings.BASE_DIR, 'apps')
|
||||
|
||||
test_suit = super(MayanTestRunner, self).build_suite(*args, **kwargs)
|
||||
|
||||
new_suite = self.test_suite()
|
||||
|
||||
# Apps that report they have tests
|
||||
if self.mayan_apps:
|
||||
args = list(args)
|
||||
args[0] = [
|
||||
app.name for app in apps.apps.get_app_configs() if getattr(
|
||||
app, 'has_tests', False
|
||||
)
|
||||
]
|
||||
|
||||
test_apps = [
|
||||
app.name for app in apps.apps.get_app_configs() if getattr(app, 'test', False)
|
||||
]
|
||||
|
||||
# Filter the test cases reported by the test runner by the apps that
|
||||
# reported tests
|
||||
|
||||
for test_case in test_suit:
|
||||
app_label = repr(test_case.__class__).split("'")[1].split('.')[0]
|
||||
if app_label in test_apps:
|
||||
new_suite.addTest(test_case)
|
||||
|
||||
print '-' * 10
|
||||
print 'Apps to test: {}'.format(', '.join(test_apps))
|
||||
print 'Total test cases: {}'.format(new_suite.countTestCases())
|
||||
print '-' * 10
|
||||
|
||||
return new_suite
|
||||
return super(MayanTestRunner, self).build_suite(*args, **kwargs)
|
||||
|
||||
@@ -14,8 +14,8 @@ from .licenses import * # NOQA
|
||||
|
||||
|
||||
class ConverterApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'converter'
|
||||
test = True
|
||||
verbose_name = _('Converter')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -26,8 +26,8 @@ from .permissions import (
|
||||
|
||||
class DjangoGPGApp(MayanAppConfig):
|
||||
app_url = 'gpg'
|
||||
has_tests = True
|
||||
name = 'django_gpg'
|
||||
test = True
|
||||
verbose_name = _('Django GPG')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -20,8 +20,8 @@ from .permissions import (
|
||||
class DocumentCommentsApp(MayanAppConfig):
|
||||
app_namespace = 'comments'
|
||||
app_url = 'comments'
|
||||
has_tests = True
|
||||
name = 'document_comments'
|
||||
test = True
|
||||
verbose_name = _('Document comments')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -44,8 +44,8 @@ from .widgets import get_instance_link, index_instance_item_link, node_level
|
||||
class DocumentIndexingApp(MayanAppConfig):
|
||||
app_namespace = 'indexing'
|
||||
app_url = 'indexing'
|
||||
has_tests = True
|
||||
name = 'document_indexing'
|
||||
test = True
|
||||
verbose_name = _('Document indexing')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -46,8 +46,8 @@ logger = logging.getLogger(__name__)
|
||||
class DocumentSignaturesApp(MayanAppConfig):
|
||||
app_namespace = 'signatures'
|
||||
app_url = 'signatures'
|
||||
has_tests = True
|
||||
name = 'document_signatures'
|
||||
test = True
|
||||
verbose_name = _('Document signatures')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -36,8 +36,8 @@ from .permissions import permission_workflow_transition
|
||||
|
||||
class DocumentStatesApp(MayanAppConfig):
|
||||
app_url = 'states'
|
||||
has_tests = True
|
||||
name = 'document_states'
|
||||
test = True
|
||||
verbose_name = _('Document states')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -82,8 +82,8 @@ from .widgets import DocumentThumbnailWidget, DocumentPageThumbnailWidget
|
||||
|
||||
|
||||
class DocumentsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'documents'
|
||||
test = True
|
||||
verbose_name = _('Documents')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -11,8 +11,8 @@ from .links import link_search, link_search_advanced, link_search_again
|
||||
class DynamicSearchApp(MayanAppConfig):
|
||||
app_namespace = 'search'
|
||||
app_url = 'search'
|
||||
has_tests = True
|
||||
name = 'dynamic_search'
|
||||
test = True
|
||||
verbose_name = _('Dynamic search')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -13,8 +13,8 @@ from .widgets import event_type_link
|
||||
|
||||
|
||||
class EventsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'events'
|
||||
test = True
|
||||
verbose_name = _('Events')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -28,8 +28,8 @@ from .permissions import (
|
||||
|
||||
|
||||
class FoldersApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'folders'
|
||||
test = True
|
||||
verbose_name = _('Folders')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -29,8 +29,8 @@ from .permissions import (
|
||||
|
||||
|
||||
class LinkingApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'linking'
|
||||
test = True
|
||||
verbose_name = _('Linking')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -5,6 +5,6 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class LockManagerApp(apps.AppConfig):
|
||||
has_tests = True
|
||||
name = 'lock_manager'
|
||||
test = True
|
||||
verbose_name = _('Lock manager')
|
||||
|
||||
@@ -21,8 +21,8 @@ from .permissions import (
|
||||
|
||||
|
||||
class MailerApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'mailer'
|
||||
test = True
|
||||
verbose_name = _('Mailer')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -47,8 +47,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MetadataApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'metadata'
|
||||
test = True
|
||||
verbose_name = _('Metadata')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -17,8 +17,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MOTDApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'motd'
|
||||
test = True
|
||||
verbose_name = _('Message of the day')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -6,6 +6,6 @@ from common.apps import MayanAppConfig
|
||||
|
||||
|
||||
class NavigationApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'navigation'
|
||||
test = True
|
||||
verbose_name = _('Navigation')
|
||||
|
||||
@@ -48,8 +48,8 @@ def document_version_ocr_submit(self):
|
||||
|
||||
|
||||
class OCRApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'ocr'
|
||||
test = True
|
||||
verbose_name = _('OCR')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -17,8 +17,8 @@ from .links import (
|
||||
|
||||
|
||||
class PermissionsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'permissions'
|
||||
test = True
|
||||
verbose_name = _('Permissions')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -13,8 +13,8 @@ from .widgets import setting_widget
|
||||
class SmartSettingsApp(MayanAppConfig):
|
||||
app_namespace = 'settings'
|
||||
app_url = 'settings'
|
||||
has_tests = True
|
||||
name = 'smart_settings'
|
||||
test = True
|
||||
verbose_name = _('Smart settings')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -33,8 +33,8 @@ from .widgets import StagingFileThumbnailWidget
|
||||
|
||||
|
||||
class SourcesApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'sources'
|
||||
test = True
|
||||
verbose_name = _('Sources')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -19,8 +19,8 @@ from .tasks import task_execute_statistic # NOQA - Force registration of task
|
||||
|
||||
|
||||
class StatisticsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'statistics'
|
||||
test = True
|
||||
verbose_name = _('Statistics')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -29,8 +29,8 @@ from .widgets import widget_document_tags, widget_single_tag
|
||||
|
||||
|
||||
class TagsApp(MayanAppConfig):
|
||||
has_tests = True
|
||||
name = 'tags'
|
||||
test = True
|
||||
verbose_name = _('Tags')
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -37,8 +37,8 @@ def get_users():
|
||||
|
||||
class UserManagementApp(MayanAppConfig):
|
||||
app_url = 'accounts'
|
||||
has_tests = True
|
||||
name = 'user_management'
|
||||
test = True
|
||||
verbose_name = _('User management')
|
||||
|
||||
def ready(self):
|
||||
|
||||
2
tox.ini
2
tox.ini
@@ -12,7 +12,7 @@ basepython =
|
||||
py35: python3.5
|
||||
|
||||
commands=
|
||||
coverage run {envdir}/bin/django-admin.py test --settings=mayan.settings.testing --nomigrations
|
||||
coverage run {envdir}/bin/django-admin.py test --mayan-apps --settings=mayan.settings.testing --nomigrations
|
||||
|
||||
deps =
|
||||
-rrequirements/testing-no-django.txt
|
||||
|
||||
Reference in New Issue
Block a user