Add management command to run tests from app list built dynamically.

This commit is contained in:
Roberto Rosario
2015-10-10 03:24:57 -04:00
parent 07f02b8f0b
commit 976a86947e
17 changed files with 42 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ from .models import AccessControlList
class ACLsApp(MayanAppConfig):
name = 'acls'
test = True
verbose_name = _('ACLs')
def ready(self):

View File

@@ -13,6 +13,7 @@ logger = logging.getLogger(__name__)
class AuthenticationApp(MayanAppConfig):
name = 'authentication'
test = True
verbose_name = _('Authentication')
def ready(self):

View File

@@ -30,6 +30,7 @@ from .tasks import task_check_expired_check_outs # NOQA
class CheckoutsApp(MayanAppConfig):
name = 'checkouts'
test = True
verbose_name = _('Checkouts')
def ready(self):

View File

@@ -63,6 +63,7 @@ class MayanAppConfig(apps.AppConfig):
class CommonApp(MayanAppConfig):
app_url = ''
name = 'common'
test = True
verbose_name = _('Common')
def ready(self):

View File

@@ -0,0 +1,26 @@
from __future__ import unicode_literals
from optparse import make_option
from django import apps
from django.core import management
class Command(management.BaseCommand):
help = 'Run all configured tests for the project.'
option_list = management.BaseCommand.option_list + (
make_option('--nomigrations', action='store_true', dest='nomigrations', default=False,
help='Don\'t use migrations when creating the test database.'),
)
def handle(self, *args, **options):
kwargs = {}
if options.get('nomigrations'):
kwargs['nomigrations'] = True
test_apps = [app.name for app in apps.apps.get_app_configs() if getattr(app, 'test', False)]
print 'Testing: {}'.format(', '.join(test_apps))
management.call_command('test', *test_apps, interactive=False, **kwargs)

View File

@@ -18,6 +18,7 @@ from .links import (
class DjangoGPGApp(MayanAppConfig):
app_url = 'gpg'
name = 'django_gpg'
test = True
verbose_name = _('Django GPG')
def ready(self):

View File

@@ -41,6 +41,7 @@ class DocumentIndexingApp(MayanAppConfig):
app_namespace = 'indexing'
app_url = 'indexing'
name = 'document_indexing'
test = True
verbose_name = _('Document indexing')
def ready(self):

View File

@@ -59,6 +59,7 @@ class DocumentSignaturesApp(MayanAppConfig):
app_namespace = 'signatures'
app_url = 'signatures'
name = 'document_signatures'
test = True
verbose_name = _('Document signatures')
def ready(self):

View File

@@ -82,6 +82,7 @@ from .widgets import document_thumbnail
class DocumentsApp(MayanAppConfig):
name = 'documents'
test = True
verbose_name = _('Documents')
def ready(self):

View File

@@ -12,6 +12,7 @@ class DynamicSearchApp(MayanAppConfig):
app_namespace = 'search'
app_url = 'search'
name = 'dynamic_search'
test = True
verbose_name = _('Dynamic search')
def ready(self):

View File

@@ -30,6 +30,7 @@ from .permissions import (
class FoldersApp(MayanAppConfig):
name = 'folders'
test = True
verbose_name = _('Folders')
def ready(self):

View File

@@ -6,4 +6,5 @@ from django.utils.translation import ugettext_lazy as _
class LockManagerApp(apps.AppConfig):
name = 'lock_manager'
test = True
verbose_name = _('Lock manager')

View File

@@ -49,6 +49,7 @@ logger = logging.getLogger(__name__)
class MetadataApp(MayanAppConfig):
name = 'metadata'
test = True
verbose_name = _('Metadata')
def ready(self):

View File

@@ -53,6 +53,7 @@ def document_version_ocr_submit(self):
class OCRApp(MayanAppConfig):
name = 'ocr'
test = True
verbose_name = _('OCR')
def ready(self):

View File

@@ -19,6 +19,7 @@ from .links import (
class PermissionsApp(MayanAppConfig):
name = 'permissions'
test = True
verbose_name = _('Permissions')
def ready(self):

View File

@@ -39,6 +39,7 @@ from .widgets import staging_file_thumbnail
class SourcesApp(MayanAppConfig):
name = 'sources'
test = True
verbose_name = _('Sources')
def ready(self):

View File

@@ -30,6 +30,7 @@ from .widgets import widget_document_tags, widget_single_tag
class TagsApp(MayanAppConfig):
name = 'tags'
test = True
verbose_name = _('Tags')
def ready(self):