Add custom tests runner that replaces the custom "runtests"
management command.
This commit is contained in:
+3
-3
@@ -21,7 +21,7 @@ test:mysql:
|
|||||||
- pip install mysql-python
|
- pip install mysql-python
|
||||||
- apt-get install -qq mysql-client
|
- 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;"
|
- 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 runtests --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
|
- coverage run manage.py test --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
|
||||||
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
@@ -30,12 +30,12 @@ test:postgres:
|
|||||||
- apt-get install -qq libpq-dev
|
- apt-get install -qq libpq-dev
|
||||||
- pip install -r requirements/testing.txt
|
- pip install -r requirements/testing.txt
|
||||||
- pip install psycopg2
|
- pip install psycopg2
|
||||||
- coverage run manage.py runtests --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
|
- coverage run manage.py test --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
|
||||||
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
||||||
tags:
|
tags:
|
||||||
- postgres
|
- postgres
|
||||||
test:sqlite:
|
test:sqlite:
|
||||||
script:
|
script:
|
||||||
- pip install -r requirements/testing.txt
|
- pip install -r requirements/testing.txt
|
||||||
- coverage run manage.py runtests --settings=mayan.settings.testing.gitlab-ci --nomigrations
|
- coverage run manage.py test --settings=mayan.settings.testing.gitlab-ci --nomigrations
|
||||||
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
- bash <(curl https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t $CODECOV_TOKEN
|
||||||
|
|||||||
+3
-3
@@ -17,9 +17,9 @@ before_script:
|
|||||||
- mysql -e 'create database mayan_edms;'
|
- mysql -e 'create database mayan_edms;'
|
||||||
- psql -c 'create database mayan_edms;' -U postgres
|
- psql -c 'create database mayan_edms;' -U postgres
|
||||||
script:
|
script:
|
||||||
- if [[ $DB == mysql ]]; then coverage run manage.py runtests --settings=mayan.settings.testing.travis.db_mysql --nomigrations; fi
|
- 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 runtests --settings=mayan.settings.testing.travis.db_postgres --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 runtests --settings=mayan.settings.testing.base --nomigrations; fi
|
- if [[ $DB == sqlite ]]; then coverage run manage.py test --settings=mayan.settings.testing.base --nomigrations; fi
|
||||||
after_success:
|
after_success:
|
||||||
- coveralls
|
- coveralls
|
||||||
branches:
|
branches:
|
||||||
|
|||||||
@@ -51,9 +51,6 @@ clean-pyc:
|
|||||||
test:
|
test:
|
||||||
./manage.py test $(MODULE) --settings=mayan.settings.testing --nomigrations
|
./manage.py test $(MODULE) --settings=mayan.settings.testing --nomigrations
|
||||||
|
|
||||||
test-all:
|
|
||||||
./manage.py runtests --settings=mayan.settings.testing --nomigrations
|
|
||||||
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ Other changes
|
|||||||
- Gaussian blur
|
- Gaussian blur
|
||||||
- Unsharp masking
|
- Unsharp masking
|
||||||
|
|
||||||
|
- Add custom test runner replacing the custom management command runtests.
|
||||||
|
The 'test-all' Makefile target that called the `runtests` command has been removed too.
|
||||||
|
|
||||||
Removals
|
Removals
|
||||||
--------
|
--------
|
||||||
- Removal of the OCR_TESSERACT_PATH configuration setting.
|
- Removal of the OCR_TESSERACT_PATH configuration setting.
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django import apps
|
|
||||||
from django.core import management
|
|
||||||
|
|
||||||
|
|
||||||
class Command(management.BaseCommand):
|
|
||||||
help = 'Run all configured tests for the project.'
|
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
|
||||||
parser.add_argument(
|
|
||||||
'--nomigrations', action='store_true', dest='nomigrations',
|
|
||||||
default=False,
|
|
||||||
help='Don\'t use migrations when creating the test database.'
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
'--reverse', action='store_true', dest='reverse', default=False,
|
|
||||||
help='Reverses test cases order.'
|
|
||||||
)
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
kwargs = {}
|
|
||||||
if options.get('nomigrations'):
|
|
||||||
kwargs['nomigrations'] = True
|
|
||||||
|
|
||||||
if options.get('reverse'):
|
|
||||||
kwargs['reverse'] = 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)
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
@@ -234,6 +234,8 @@ STATICFILES_FINDERS = (
|
|||||||
'compressor.finders.CompressorFinder',
|
'compressor.finders.CompressorFinder',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TEST_RUNNER = 'common.tests.runner.MayanTestRunner'
|
||||||
|
|
||||||
# --------- Django compressor -------------
|
# --------- Django compressor -------------
|
||||||
COMPRESS_CSS_FILTERS = (
|
COMPRESS_CSS_FILTERS = (
|
||||||
'compressor.filters.css_default.CssAbsoluteFilter',
|
'compressor.filters.css_default.CssAbsoluteFilter',
|
||||||
@@ -272,7 +274,6 @@ CELERY_ROUTES = {}
|
|||||||
CELERY_TASK_SERIALIZER = 'json'
|
CELERY_TASK_SERIALIZER = 'json'
|
||||||
CELERY_TIMEZONE = 'UTC'
|
CELERY_TIMEZONE = 'UTC'
|
||||||
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
|
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
|
||||||
TEST_RUNNER = 'djcelery.contrib.test_runner.CeleryTestSuiteRunner'
|
|
||||||
# ------------ CORS ------------
|
# ------------ CORS ------------
|
||||||
CORS_ORIGIN_ALLOW_ALL = True
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
# ------ Django REST Swagger -----
|
# ------ Django REST Swagger -----
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ basepython =
|
|||||||
py35: python3.5
|
py35: python3.5
|
||||||
|
|
||||||
commands=
|
commands=
|
||||||
coverage run {envdir}/bin/django-admin.py runtests --settings=mayan.settings.testing --nomigrations
|
coverage run {envdir}/bin/django-admin.py test --settings=mayan.settings.testing --nomigrations
|
||||||
|
|
||||||
deps =
|
deps =
|
||||||
-rrequirements/testing-no-django.txt
|
-rrequirements/testing-no-django.txt
|
||||||
|
|||||||
Reference in New Issue
Block a user