From 307f07f869d06d478dcd01afc2107bad5357af42 Mon Sep 17 00:00:00 2001 From: delcroip Date: Mon, 16 Sep 2024 14:01:06 +0200 Subject: [PATCH 1/2] block deletion if used in a claim --- policy/services.py | 8 ++++++++ policy/tests/test_services.py | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/policy/services.py b/policy/services.py index 4be8865..d4de50d 100644 --- a/policy/services.py +++ b/policy/services.py @@ -135,6 +135,14 @@ def set_suspended(self, user, policy): } def set_deleted(self, policy): + + if policy.claim_ded_rems: + return { + 'title': policy.uuid, + 'list': [{ + 'message': _("policy.mutation.policy_is_used_in_claims") % {'policy': str(policy)}, + 'detail': policy.uuid}] + } try: insuree_policies = InsureePolicy.objects.filter(policy=policy) for insuree_policy in insuree_policies: diff --git a/policy/tests/test_services.py b/policy/tests/test_services.py index d77d3bc..a63f1fa 100644 --- a/policy/tests/test_services.py +++ b/policy/tests/test_services.py @@ -174,11 +174,8 @@ def eligibility_serv(self, category): native_response = native_el_svc.request(req, EligibilityResponse(req)) self.assertIsNotNone(native_response) self.assertEquals(native_response, expected_resposnse) - - + def test_eligibility_item(self): - if not connection.vendor == "mssql": - self.skipTest("This test can only be executed for MSSQL database") insuree, family = create_test_insuree_for_policy() product = create_test_product("ELI1") (policy, insuree_policy) = create_test_policy2(product, insuree) @@ -224,8 +221,6 @@ def test_eligibility_item(self): def test_eligibility_by_insuree(self): - if not connection.vendor == "mssql": - self.skipTest("This test can only be executed for MSSQL database") insuree, family = create_test_insuree_for_policy() product = create_test_product("ELI1") (policy, insuree_policy) = create_test_policy2(product, insuree) @@ -268,6 +263,9 @@ def test_eligibility_by_insuree(self): native_response = native_el_svc.request(req, native_response) self.assertIsNotNone(native_response) self.assertEquals(native_response, expected_resposnse) + result = PolicyService(self.user).set_deleted(policy) + self.assertNotEquals(result, [], "the policiy cannot be deleted as it has some demRem on it") + From bad45102f6aeec7a23a5ae4d143c47ad53d0faa1 Mon Sep 17 00:00:00 2001 From: Patrick Delcroix Date: Thu, 19 Sep 2024 14:23:25 +0200 Subject: [PATCH 2/2] Update policy/tests/test_services.py Co-authored-by: Dragos DOBRE --- policy/tests/test_services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policy/tests/test_services.py b/policy/tests/test_services.py index a63f1fa..811cc30 100644 --- a/policy/tests/test_services.py +++ b/policy/tests/test_services.py @@ -264,7 +264,7 @@ def test_eligibility_by_insuree(self): self.assertIsNotNone(native_response) self.assertEquals(native_response, expected_resposnse) result = PolicyService(self.user).set_deleted(policy) - self.assertNotEquals(result, [], "the policiy cannot be deleted as it has some demRem on it") + self.assertNotEquals(result, [], "the policy cannot be deleted as it has some DedRem on it")