~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-11 15:48:05 UTC
  • Revision ID: aurelien@bompard.org-20131011154805-9dov6x893k27jrnx
Handle 'local-part-only' acceptable aliases

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
        # it used to be a plain-text field (values are newline-separated)
214
214
        aliases = ["alias1@example.com",
215
215
                   "alias2@exemple.com",
216
 
                   "non-ascii-\xe8@example.com"]
 
216
                   "non-ascii-\xe8@example.com",
 
217
                   ]
217
218
        self._pckdict[b"acceptable_aliases"] = \
218
219
                ("\n".join(aliases)).encode("utf-8")
219
220
        self._import()
220
221
        alias_set = IAcceptableAliasSet(self._mlist)
221
222
        self.assertEqual(sorted(alias_set.aliases), aliases)
222
223
 
 
224
    def test_acceptable_aliases_invalid(self):
 
225
        # values without an '@' sign used to be matched against the local part,
 
226
        # now we need to add the '^' sign
 
227
        aliases = ["invalid-value", ]
 
228
        self._pckdict[b"acceptable_aliases"] = \
 
229
                ("\n".join(aliases)).encode("utf-8")
 
230
        try:
 
231
            self._import()
 
232
        except ValueError, e:
 
233
            print(format_exc())
 
234
            self.fail("Invalid value '%s' caused a crash" % e)
 
235
        alias_set = IAcceptableAliasSet(self._mlist)
 
236
        self.assertEqual(sorted(alias_set.aliases),
 
237
                         [ ("^" + a) for a in aliases ])
 
238
 
223
239
    def test_info_non_ascii(self):
224
240
        # info can contain non-ascii chars
225
241
        info = 'O idioma aceito \xe9 somente Portugu\xeas do Brasil'