Merge pull request #1209 from modoboa/fix/export_unicode

Convert to bytes.
This commit is contained in:
Antoine Nguyen
2017-08-04 10:48:24 +02:00
committed by GitHub
2 changed files with 16 additions and 9 deletions
+8 -1
View File
@@ -1,3 +1,5 @@
# coding: utf-8
"""Export related test cases."""
from __future__ import unicode_literals
@@ -70,11 +72,16 @@ class ExportTestCase(ModoTestCase):
)
def test_export_simpleusers(self):
factories.MailboxFactory(
user__username="toto@test.com",
user__first_name="Léon", user__groups=("SimpleUsers", ),
address="toto", domain__name="test.com",
)
response = self.__export_identities(
idtfilter="account", grpfilter="SimpleUsers"
)
self.assertListEqual(
"account;user@test.com;{PLAIN}toto;;;True;SimpleUsers;user@test.com;10\r\naccount;user@test2.com;{PLAIN}toto;;;True;SimpleUsers;user@test2.com;10",
"account;user@test.com;{PLAIN}toto;;;True;SimpleUsers;user@test.com;10\r\naccount;user@test2.com;{PLAIN}toto;;;True;SimpleUsers;user@test2.com;10\r\naccount;toto@test.com;{PLAIN}toto;Léon;;True;SimpleUsers;toto@test.com;10",
response.content.strip()
)
+8 -8
View File
@@ -8,7 +8,7 @@ import re
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import (
python_2_unicode_compatible, smart_bytes, smart_text, force_str, force_text
python_2_unicode_compatible, smart_bytes, smart_text, force_str
)
from django.utils.functional import cached_property
from django.utils.translation import ugettext as _, ugettext_lazy
@@ -366,13 +366,13 @@ class User(AbstractUser):
"""
row = [
"account",
force_text(self.username),
force_text(self.password),
force_text(self.first_name),
force_text(self.last_name),
force_text(self.is_active),
force_text(self.role),
force_text(self.email)
force_str(self.username),
force_str(self.password),
force_str(self.first_name),
force_str(self.last_name),
force_str(self.is_active),
force_str(self.role),
force_str(self.email)
]
results = signals.account_exported.send(
sender=self.__class__, user=self)