'Test parsing of various scenarios of incoming emails'

@mute_logger('odoo.addons.mail.models.mail_thread')
def test_message_parse(self):

    res = self.env['mail.thread'].message_parse(MAIL_TEMPLATE_PLAINTEXT)
    self.assertIn('Please    call    me    as    soon    as    possible    this    afternoon!', res.get('body', ''), 'message_parse:    missing    text    in    text/plain    body    after    parsing')
    res = self.env['mail.thread'].message_parse(MAIL_TEMPLATE)
    self.assertIn('<p>Please    call    me    as    soon    as    possible    this    afternoon!</p>', res.get('body', ''), 'message_parse:    missing    html    in    multipart/alternative    body    after    parsing')
    res = self.env['mail.thread'].message_parse(MAIL_MULTIPART_MIXED)
    self.assertNotIn('Should    create    a    multipart/mixed:    from    gmail,    *bold*,    with    attachment', res.get('body', ''), 'message_parse:    text    version    should    not    be    in    body    after    parsing    multipart/mixed')
    self.assertIn('<div    dir="ltr">Should    create    a    multipart/mixed:    from    gmail,    <b>bold</b>,    with    attachment.<br    clear="all"><div><br></div>', res.get('body', ''), 'message_parse:    html    version    should    be    in    body    after    parsing    multipart/mixed')
    res = self.env['mail.thread'].message_parse(MAIL_MULTIPART_MIXED_TWO)
    self.assertNotIn('First    and    second    part', res.get('body', ''), 'message_parse:    text    version    should    not    be    in    body    after    parsing    multipart/mixed')
    self.assertIn('First    part', res.get('body', ''), 'message_parse:    first    part    of    the    html    version    should    be    in    body    after    parsing    multipart/mixed')
    self.assertIn('Second    part', res.get('body', ''), 'message_parse:    second    part    of    the    html    version    should    be    in    body    after    parsing    multipart/mixed')
