allow to use tox to run tests/serve locally in an easy way

This commit is contained in:
Gael Pasgrimaud
2016-09-13 11:47:21 +02:00
parent 9d3d0b59f7
commit c87240eefb
7 changed files with 58 additions and 7 deletions
+1
View File
@@ -1,6 +1,7 @@
.*~$
*.pyc
*.mo
modoboa_test.db
modoboa.egg-info
doc/.build
doc/.static
+4
View File
@@ -1,5 +1,7 @@
# coding: utf-8
from unittest import skipIf
from django.core.urlresolvers import reverse
from django.test import override_settings
@@ -7,6 +9,7 @@ from modoboa.core.models import User
from modoboa.core import tests as core_tests
from modoboa.lib import parameters
from modoboa.lib.tests import ModoTestCase
from modoboa.lib.tests import NO_LDAP
from .. import factories
from .. import models
@@ -171,6 +174,7 @@ class AccountTestCase(ModoTestCase):
self.assertIn("Resources usage", response.content)
@skipIf(NO_LDAP, 'No ldap module installed')
@override_settings(AUTHENTICATION_BACKENDS=(
'modoboa.lib.authbackends.LDAPBackend',
'modoboa.lib.authbackends.SimpleBackend',
+4
View File
@@ -1,5 +1,7 @@
"""Tests for core application."""
from unittest import skipIf
import httmock
from django.core import management
@@ -9,6 +11,7 @@ from django.test import override_settings
from modoboa.lib import exceptions
from modoboa.lib import parameters
from modoboa.lib.tests import ModoTestCase
from modoboa.lib.tests import NO_LDAP
from . import factories
from . import mocks
@@ -44,6 +47,7 @@ class AuthenticationTestCase(ModoTestCase):
self.assertTrue(response.url.endswith(reverse("admin:domain_list")))
@skipIf(NO_LDAP, 'No ldap module installed')
class LDAPTestCaseMixin(object):
"""Set of methods used to test LDAP features."""
+6
View File
@@ -13,6 +13,12 @@ from rest_framework.test import APITestCase
from modoboa.lib import parameters
from modoboa.core import models as core_models
try:
import ldap # NOQA
NO_LDAP = False
except ImportError:
NO_LDAP = True
class ModoTestCase(TestCase):
+12
View File
@@ -20,6 +20,18 @@ if DB == 'MYSQL':
},
}
if DB == 'SQLITE':
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'modoboa_test.db',
'PORT': '',
'ATOMIC_REQUESTS': True,
},
}
else:
DATABASES = {
+8 -7
View File
@@ -14,7 +14,7 @@ from logging.handlers import SysLogHandler
from django.conf import global_settings
from modoboa.test_settings import *
from modoboa.test_settings import * # NOQA
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
@@ -26,12 +26,13 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
SECRET_KEY = '!8o(-dbbl3e+*bh7nx-^xysdt)1gso*%@4ze4-9_9o+i&t--u_'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = 'DEBUG' in os.environ
TEMPLATE_DEBUG = False
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = [
'localhost'
'127.0.0.1',
'localhost',
]
SITE_ID = 1
@@ -112,7 +113,7 @@ USE_TZ = True
STATIC_URL = '/sitestatic/'
STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic')
STATICFILES_DIRS = (
'/home/tonio/.pythonenvs/modoboa/lib/python2.7/site-packages/modoboa-1.3.3-py2.7.egg/modoboa/bower_components',
os.path.join(BASE_DIR, '..', 'modoboa', 'bower_components'),
)
MEDIA_URL = '/media/'
@@ -130,9 +131,9 @@ REST_FRAMEWORK = {
}
# Modoboa settings
#MODOBOA_CUSTOM_LOGO = os.path.join(MEDIA_URL, "custom_logo.png")
# MODOBOA_CUSTOM_LOGO = os.path.join(MEDIA_URL, "custom_logo.png")
#DOVECOT_LOOKUP_PATH = ('/path/to/dovecot', )
# DOVECOT_LOOKUP_PATH = ('/path/to/dovecot', )
MODOBOA_API_URL = 'http://api.modoboa.org/1/'
+23
View File
@@ -0,0 +1,23 @@
[tox]
envlist = py27
[testenv]
changedir=test_project
commands =
python ../tests.py
coverage run --source ../modoboa manage.py test modoboa.core modoboa.lib modoboa.admin.tests modoboa.limits modoboa.relaydomains
deps =
-r{toxinidir}/test-requirements.txt
coverage
psycopg2
setenv =
DB=SQLITE
[testenv:serve]
changedir=test_project
commands =
python manage.py migrate --no-input
python manage.py runserver
setenv =
DB=SQLITE
DEBUG=1