[PATCH 6/6] parsemail tests: add test for mail with utf-8
Daniel Axtens
dja at axtens.net
Mon Sep 26 08:15:05 AEST 2016
> I think this can be squashed into the previous patch, but otherwise:
>
> Reviewed-by: Stephen Finucane <stephenfinucane at hotmail.com>
Fair point. Will squash it for v2.
Regards,
Daniel
>
>> patchwork/tests/test_management.py | 29 +++++++++++++++++++++++++++++
>> 1 file changed, 29 insertions(+)
>>
>> diff --git a/patchwork/tests/test_management.py b/patchwork/tests/test_management.py
>> index 5f97aa76866f..4b49131a72c2 100644
>> --- a/patchwork/tests/test_management.py
>> +++ b/patchwork/tests/test_management.py
>> @@ -81,3 +81,32 @@ class ParsemailTest(TestCase):
>>
>> count = models.Patch.objects.filter(project=project.id).count()
>> self.assertEqual(count, 1)
>> +
>> + def test_utf8_path(self):
>> + project = utils.create_project()
>> + utils.create_state()
>> +
>> + path = os.path.join(TEST_MAIL_DIR, '0013-with-utf8-body.mbox')
>> + with self.assertRaises(SystemExit) as exc:
>> + call_command('parsemail', infile=path, list_id=project.listid)
>> +
>> + self.assertEqual(exc.exception.code, 0)
>> +
>> + count = models.Patch.objects.filter(project=project.id).count()
>> + self.assertEqual(count, 1)
>> +
>> + def test_utf8_stdin(self):
>> + project = utils.create_project()
>> + utils.create_state()
>> +
>> + path = os.path.join(TEST_MAIL_DIR, '0013-with-utf8-body.mbox')
>> + sys.stdin.close()
>> + sys.stdin = open(path)
>
> Yeah, this makes more sense.
>
>> + with self.assertRaises(SystemExit) as exc:
>> + call_command('parsemail', infile=None,
>> + list_id=project.listid)
>> +
>> + self.assertEqual(exc.exception.code, 0)
>> +
>> + count = models.Patch.objects.filter(project=project.id).count()
>> + self.assertEqual(count, 1)
>> --
>> 2.7.4
>>
More information about the Patchwork
mailing list