Fix unit tests.

see #860
This commit is contained in:
Antoine Nguyen
2016-04-14 14:37:18 +02:00
parent f786a96258
commit c66f89764c
3 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -10,6 +10,8 @@ from modoboa.lib.web_utils import (
_render_error, ajax_response, render_to_json_response
)
from . import singleton
class AjaxLoginRedirect(object):
@@ -41,10 +43,13 @@ class CommonExceptionCatcher(object):
)
class RequestCatcherMiddleware(object):
class RequestCatcherMiddleware(singleton.Singleton):
"""Simple middleware to store the current request.
"""
Simple middleware to store the current request.
FIXME: the Singleton hack is used to make tests work. I don't know
why but middlewares are not dropped between test case runs so more
than one instance can be listening to the request_accessor signal
and we don't want that!
"""
def __init__(self):
+1 -1
View File
@@ -37,7 +37,7 @@ def create_user_limits(sender, instance, **kwargs):
ct = ContentType.objects.get_by_natural_key(
*definition["content_type"].split("."))
max_value = 0
if not creator or creator.is_superuser:
if creator and creator.is_superuser:
max_value = int(
parameters.get_admin("DEFLT_{}_LIMIT".format(name.upper())))
models.ObjectLimit.objects.create(
+1 -1
View File
@@ -180,7 +180,6 @@ class ResellerTestCase(ResourceTestCase):
cls.user = UserFactory(
username='reseller', groups=('Resellers',)
)
cls.user.objectlimit_set.update(max_value=2)
def setUp(self):
"""Test initialization."""
@@ -329,6 +328,7 @@ class ResellerTestCase(ResourceTestCase):
self._check_limit('mailbox_aliases', 0, 2)
def test_restore_resources(self):
"""Give resource to a domain admin and restore them."""
self._create_domain('domain.tld')
dom = Domain.objects.get(name='domain.tld')
self._create_account('admin1@domain.tld', role='DomainAdmins')