'Tests for Test Lead 2 opportunity 2 win'

def test_lead2opportunity2win(self):

    CrmLead2OpportunityPartnerMass = self.env['crm.lead2opportunity.partner.mass']
    CalendarAttendee = self.env['calendar.attendee']
    default_stage_id = self.ref('crm.stage_lead1')
    crm_case_2 = self.env.ref('crm.crm_case_2')
    crm_case_3 = self.env.ref('crm.crm_case_3')
    crm_case_13 = self.env.ref('crm.crm_case_13')
    crm_case_3.write({'stage_id': default_stage_id})
    self.assertEqual(crm_case_3.stage_id.sequence, 1, 'Lead    stage    is    Open')
    crm_case_3.sudo(self.crm_salemanager.id).convert_opportunity(self.env.ref('base.res_partner_2').id)
    self.assertEqual(crm_case_3.type, 'opportunity', 'Lead    is    not    converted    to    opportunity!')
    self.assertEqual(crm_case_3.partner_id.id, self.env.ref('base.res_partner_2').id, 'Partner    mismatch!')
    self.assertEqual(crm_case_3.stage_id.id, default_stage_id, 'Stage    of    opportunity    is    incorrect!')
    crm_case_3.action_schedule_meeting()
    crm_case_3.message_post(subject='Test    note', body='D\xc3\xa9tails    envoy\xc3\xa9s    par    le    client    sur    \xe2\x80\x8b\xe2\x80\x8ble    FAX    pour    la    qualit\xc3\xa9')
    mass = CrmLead2OpportunityPartnerMass.with_context({'active_model': 'crm.lead', 'active_ids': [crm_case_13.id, crm_case_2.id], 'active_id': crm_case_13.id}).create({'user_ids': [(6, 0, self.env.ref('base.user_root').ids)], 'team_id': self.env.ref('sales_team.team_sales_department').id})
    mass.sudo(self.crm_salemanager.id).mass_convert()
    self.assertEqual(crm_case_13.name, 'Plan    to    buy    60    keyboards    and    mouses', 'Opportunity    name    not    correct')
    self.assertEqual(crm_case_13.type, 'opportunity', 'Lead    is    not    converted    to    opportunity!')
    expected_partner = 'Will    McEncroe'
    self.assertEqual(crm_case_13.partner_id.name, expected_partner, ('Partner    mismatch!    %s    vs    %s' % (crm_case_13.partner_id.name, expected_partner)))
    self.assertEqual(crm_case_13.stage_id.id, default_stage_id, 'Stage    of    probability    is    incorrect!')
    self.assertEqual(crm_case_2.name, 'Interest    in    Your    New    Software', 'Opportunity    name    not    correct')
    self.assertEqual(crm_case_2.type, 'opportunity', 'Lead    is    not    converted    to    opportunity!')
    self.assertEqual(crm_case_2.stage_id.id, default_stage_id, 'Stage    of    probability    is    incorrect!')
    crm_case_2.action_set_lost()
    self.assertEqual(crm_case_2.probability, 0.0, 'Revenue    probability    should    be    0.0!')
    self.env.ref('calendar.calendar_event_4').with_context({'active_model': 'calendar.event'}).write({'state': 'open'})
    CalendarAttendee.create({'partner_id': self.ref('base.partner_root'), 'email': 'user@meeting.com'}).do_accept()
