~abompard/mailman/import21

« back to all changes in this revision

Viewing changes to src/mailman/utilities/tests/test_import.py

  • Committer: Aurélien Bompard
  • Date: 2013-10-03 16:37:04 UTC
  • Revision ID: aurelien@bompard.org-20131003163704-d9p7wz110x91p25f
More unicode fixes in the import script

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
        self._import()
169
169
        self.assertEqual(self._mlist.moderator_password, None)
170
170
 
 
171
    def test_moderator_password_str(self):
 
172
        # moderator_password must not be unicode
 
173
        self._pckdict[b"mod_password"] = b'TESTVALUE'
 
174
        self._import()
 
175
        self.assertEqual(self._mlist.moderator_password, b'TESTVALUE')
 
176
 
171
177
    def test_newsgroup_moderation(self):
172
178
        # news_moderation -> newsgroup_moderation
173
179
        # news_prefix_subject_too -> nntp_prefix_subject_too
205
211
        alias_set = IAcceptableAliasSet(self._mlist)
206
212
        self.assertEqual(sorted(alias_set.aliases), aliases)
207
213
 
 
214
    def test_info_non_ascii(self):
 
215
        # info can contain non-ascii chars
 
216
        info = 'O idioma aceito \xe9 somente Portugu\xeas do Brasil'
 
217
        self._pckdict[b"info"] = info.encode("utf-8")
 
218
        self._import()
 
219
        self.assertEqual(self._mlist.info, info,
 
220
                         "Encoding to UTF-8 is not handled")
 
221
        # test fallback to ascii with replace
 
222
        self._pckdict[b"info"] = info.encode("iso-8859-1")
 
223
        self._import()
 
224
        self.assertEqual(self._mlist.info,
 
225
                         unicode(self._pckdict[b"info"], "ascii", "replace"),
 
226
                         "We don't fall back to replacing non-ascii chars")
 
227
 
208
228
 
209
229
 
210
230
class TestArchiveImport(unittest.TestCase):
560
580
            user = self._usermanager.get_user(addr)
561
581
            self.assertTrue(user is not None,
562
582
                    "Address %s was not imported" % addr)
563
 
            self.assertEqual(user.password, '{plaintext}%spass' % name,
 
583
            self.assertEqual(user.password, b'{plaintext}%spass' % name,
564
584
                    "Password for %s was not imported" % addr)
565
585
 
566
586
    def test_same_user(self):