def test_save_lead_and_active_client(self): lead = Lead.objects.get(id=1) lead.state = "LOST" lead.save() lead = Lead.objects.get(id=1) self.assertTrue(lead.client.active) # There's still anotger active lead for this client otherLead = Lead.objects.get(id=3) otherLead.state = "SLEEPING" otherLead.save() lead = Lead.objects.get(id=1) self.assertFalse(lead.client.active) newLead = Lead() newLead.subsidiary_id = 1 newLead.client = lead.client newLead.save() self.assertTrue(lead.client.active) # A new lead on this client should mark it as active again
def test_save_lead_and_active_client(self): lead = Lead.objects.get(id=1) lead.state = "LOST" lead.save() lead = Lead.objects.get(id=1) self.assertTrue(lead.client.active) # There's still anotger active lead for this client otherLead = Lead.objects.get(id=3) otherLead.state = "SLEEPING" otherLead.save() lead = Lead.objects.get(id=1) self.assertFalse(lead.client.active) newLead = Lead() newLead.subsidiary_id = 1 newLead.client = lead.client newLead.save() lead = Lead.objects.get(id=1) self.assertTrue(lead.client.active) # A new lead on this client should mark it as active again