From d821e08ca72021074598c78ee7908346a5f665a4 Mon Sep 17 00:00:00 2001 From: jefer94 Date: Wed, 18 Sep 2024 19:04:54 -0500 Subject: [PATCH] fix tests and an undefined variable error --- breathecode/assignments/tests/urls/tests_user_me_task.py | 6 +++--- breathecode/cypress/tests/urls/tests_load_roles.py | 2 +- breathecode/payments/tasks.py | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/breathecode/assignments/tests/urls/tests_user_me_task.py b/breathecode/assignments/tests/urls/tests_user_me_task.py index eff33f8b6..193c2836e 100644 --- a/breathecode/assignments/tests/urls/tests_user_me_task.py +++ b/breathecode/assignments/tests/urls/tests_user_me_task.py @@ -629,10 +629,10 @@ def test__put__with_task__one_item_in_body__passing_revision_status(self): @patch("django.db.models.signals.pre_delete.send_robust", MagicMock(return_value=None)) @patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None)) def test__put__with_task__one_item_in_body__passing_revision_status__teacher_token(self): - statuses = ["APPROVED", "REJECTED", "IGNORED"] - for index in range(0, 3): + statuses = ["APPROVED", "REJECTED"] + for index in range(0, 2): current_status = statuses[index] - next_status = statuses[index - 1 if index > 0 else 2] + next_status = statuses[index - 1 if index > 0 else 1] task = {"revision_status": current_status, "task_status": "DONE"} cohort_users = [ { diff --git a/breathecode/cypress/tests/urls/tests_load_roles.py b/breathecode/cypress/tests/urls/tests_load_roles.py index fc0b11920..6e333ba9b 100644 --- a/breathecode/cypress/tests/urls/tests_load_roles.py +++ b/breathecode/cypress/tests/urls/tests_load_roles.py @@ -495,7 +495,7 @@ def test_load_roles__check_the_capabilities(self): for capability in CAPABILITIES: self.assertRegex(capability["slug"], r"^[a-z_]+$") - self.assertRegex(capability["description"], r'^[a-zA-Z,. _()"]+$') + self.assertRegex(capability["description"], r'^[a-zA-Z,. _()"\']+$') self.assertEqual(len(capability), 2) def test_load_roles__check_the_roles(self): diff --git a/breathecode/payments/tasks.py b/breathecode/payments/tasks.py index 477d7b3d2..e3bf7491e 100644 --- a/breathecode/payments/tasks.py +++ b/breathecode/payments/tasks.py @@ -286,11 +286,13 @@ def alert_payment_issue(message: str, button: str) -> None: academy=subscription.academy, ) - bag.delete() + if bag: + bag.delete() subscription.status = "PAYMENT_ISSUE" subscription.save() + bag = None client = None if IS_DJANGO_REDIS: client = get_redis_connection("default") @@ -462,11 +464,13 @@ def alert_payment_issue(message: str, button: str) -> None: academy=plan_financing.academy, ) - bag.delete() + if bag: + bag.delete() plan_financing.status = "PAYMENT_ISSUE" plan_financing.save() + bag = None client = None if IS_DJANGO_REDIS: client = get_redis_connection("default")