test: remove sla if no active sla found

This commit is contained in:
Saqib Ansari 2022-01-14 18:17:40 +05:30
parent b31679b6ef
commit cc88b31f1f
2 changed files with 8 additions and 1 deletions

View File

@ -385,7 +385,7 @@ def apply(doc, method=None):
sla = get_active_service_level_agreement_for(doc)
if not sla:
remove_sla_if_applied()
remove_sla_if_applied(doc)
return
process_sla(doc, sla)

View File

@ -244,6 +244,13 @@ class TestServiceLevelAgreement(unittest.TestCase):
applied_sla = frappe.db.get_value('Lead', lead.name, 'service_level_agreement')
self.assertEqual(applied_sla, lead_sla.name)
# check if SLA is removed if condition fails
lead.reload()
lead.source = None
lead.save()
applied_sla = frappe.db.get_value('Lead', lead.name, 'service_level_agreement')
self.assertFalse(applied_sla)
def tearDown(self):
for d in frappe.get_all("Service Level Agreement"):
frappe.delete_doc("Service Level Agreement", d.name, force=1)