Skip to content

Commit

Permalink
add avoid rescheduling fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Dec 7, 2024
1 parent cfa0e01 commit 4b43066
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/task_manager/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present jefer94 <[email protected]>
#
# SPDX-License-Identifier: LGPL-3.0-or-later
__version__ = "1.8.0"
__version__ = "1.9.0"
1 change: 0 additions & 1 deletion src/task_manager/django/dispatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from datetime import datetime
from typing import Any, Type

from asgiref.sync import sync_to_async
Expand Down
1 change: 1 addition & 0 deletions src/task_manager/pytest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .core import * # noqa: F401
3 changes: 3 additions & 0 deletions src/task_manager/pytest/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Centralized Breathecode fixtures for all our libraries."""

from .fixtures import * # noqa: F401
1 change: 1 addition & 0 deletions src/task_manager/pytest/core/fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .dont_wait_for_rescheduling_tasks import * # noqa: F401
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Generator
from unittest.mock import patch

import pytest

__all__ = ["dont_wait_for_rescheduling_tasks"]


@pytest.fixture(autouse=True)
def dont_wait_for_rescheduling_tasks() -> Generator[None, None, None]:
"""
Don't wait for rescheduling tasks by default.
You can re-enable it within a test by calling the provided wrapper.
"""

from task_manager.core.settings import set_settings

set_settings(RETRIES_LIMIT=2)

with patch(
"task_manager.core.decorators.Task.reattempt_settings",
lambda *args, **kwargs: dict(),
):
with patch(
"task_manager.core.decorators.Task.circuit_breaker_settings",
lambda *args, **kwargs: dict(),
):
yield

0 comments on commit 4b43066

Please sign in to comment.