'Test newly create leads like from the website. People and channels
subscribed to the sales team shoud be notified.'

def test_new_lead_notification(self):

    subtype = self.env.ref('crm.mt_salesteam_lead')
    self.sales_team_1.message_subscribe(partner_ids=[self.user_salesman_all.partner_id.id], subtype_ids=[subtype.id])
    self.sales_team_1.message_subscribe(channel_ids=[self.group_pigs.id], subtype_ids=[subtype.id])
    lead = self.env['crm.lead'].with_context(mail_create_nosubscribe=True).sudo().create({'contact_name': 'Somebody', 'description': 'Some    question', 'email_from': 'somemail@example.com', 'name': 'Some    subject', 'partner_name': 'Some    company', 'team_id': self.sales_team_1.id, 'phone': '+0000000000'})
    self.assertIn(self.user_salesman_all.partner_id, lead.message_partner_ids)
    self.assertIn(self.group_pigs, lead.message_channel_ids)
    msg = lead.message_ids[0]
    self.assertIn(self.user_salesman_all.partner_id, msg.needaction_partner_ids)
    self.assertIn(self.group_pigs, msg.channel_ids)
    lead_user = lead.sudo(self.user_salesman_all)
    self.assertTrue(lead_user.message_needaction)
