fix tests for modoboa.core in python2

This commit is contained in:
Arthur Vuillard
2017-05-11 15:17:20 +02:00
parent 3114ae368b
commit c97e5a703d
4 changed files with 6 additions and 9 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ class ImportDataForm(forms.Form):
def clean_sepchar(self):
if self.cleaned_data["sepchar"] == "":
return ";"
return str(self.cleaned_data["sepchar"])
return self.cleaned_data["sepchar"]
class ImportIdentitiesForm(ImportDataForm):
+2 -4
View File
@@ -2,8 +2,6 @@
from __future__ import unicode_literals
import json
from testfixtures import compare
from django import forms
@@ -53,12 +51,12 @@ class DashboardTestCase(ModoTestCase):
url = reverse("core:dashboard")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn("Latest news", str(response.content))
self.assertIn("Latest news", response.content.decode('utf-8'))
self.client.logout()
self.client.login(username=self.dadmin.username, password="toto")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn("Latest news", str(response.content))
self.assertIn("Latest news", response.content.decode('utf-8'))
self.client.logout()
self.client.login(username=self.user.username, password="toto")
response = self.client.get(url)
+3 -2
View File
@@ -39,6 +39,7 @@ import ldap
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.encoding import smart_bytes
from modoboa.core.password_hashers import get_password_hasher
from modoboa.lib.exceptions import InternalError
@@ -119,8 +120,8 @@ class LDAPAuthBackend(object):
('"%s"' % newpassword).encode('utf-16').lstrip('\377\376')
)
ldif = [(ldap.MOD_REPLACE,
self.pwd_attr,
self._crypt_password(newpassword))]
smart_bytes(self.pwd_attr),
smart_bytes(self._crypt_password(newpassword)))]
try:
self.conn.modify_s(user_dn, ldif)
except ldap.LDAPError as e:
-2
View File
@@ -3,8 +3,6 @@
from __future__ import unicode_literals
import json
from django.core import management
from django.test import TestCase