Merge pull request #912 from bearstech/tox

allow to use tox to run tests/serve locally in an easy way
This commit is contained in:
Antoine Nguyen
2016-09-13 14:14:47 +02:00
committed by GitHub
7 changed files with 60 additions and 7 deletions
+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
@@ -194,6 +197,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, TestCase
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
@@ -93,6 +96,7 @@ class DashboardTestCase(ModoTestCase):
self.assertTrue(response.url.endswith(reverse("core:dashboard")))
@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 = {