Skip to content

Commit

Permalink
chore: remove NtfyBackendExponentialRateLimitBackend and SmtpExponent…
Browse files Browse the repository at this point in the history
…ialRateLimitEmailBackend

They can be easily replaced by ExponentialRateLimitBackends where the
list of backends is NtfyBackend or Emailbackend
  • Loading branch information
shenek committed Feb 13, 2024
1 parent 2cc033f commit 0ad53ad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 65 deletions.
9 changes: 0 additions & 9 deletions django_ntfy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from django.core.cache import cache
from django.core.mail import EmailMessage
from django.core.mail.backends.base import BaseEmailBackend
from django.core.mail.backends.smtp import EmailBackend
from django.utils.module_loading import import_string
from django.utils.text import slugify

Expand Down Expand Up @@ -149,14 +148,6 @@ def send_messages(self, email_messages: typing.List[EmailMessage]):
return count


class NtfyBackendExponentialRateLimitBackend(ExponentialRateLimitMixin, NtfyBackend):
pass


class SmtpExponentialRateLimitEmailBackend(ExponentialRateLimitMixin, EmailBackend):
pass


class ExponentialRateLimitBackends(BaseEmailBackend):
def __init__(self, *args, **kwargs):
backend_strings = getattr(
Expand Down
12 changes: 0 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ def use_ntfy_backend(settings):
settings.EMAIL_BACKEND = 'django_ntfy.NtfyBackend'


@pytest.fixture
def use_smtp_exponential_ratelimit_backend(settings):
# we need to explicitly override it here
settings.EMAIL_BACKEND = 'django_ntfy.SmtpExponentialRateLimitEmailBackend'


@pytest.fixture
def use_ntfy_exponential_ratelimit_backend(settings):
# we need to explicitly override it here
settings.EMAIL_BACKEND = 'django_ntfy.NtfyBackendExponentialRateLimitBackend'


@pytest.fixture
def use_exponential_ratelimit_backends(settings):
# we need to explicitly override it here
Expand Down
6 changes: 5 additions & 1 deletion tests/test_ntfy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ def test_priority_signal(settings, use_ntfy_backend, priority_signal):
assert mail.send_mail("Sub", "Body", "[email protected]", ["[email protected]"]) == 1


def test_exponential_rate_limit(settings, use_ntfy_exponential_ratelimit_backend, clear_cache):
def test_exponential_rate_limit(settings, use_exponential_ratelimit_backends, clear_cache):
settings.EMAIL_EXPONENTIAL_RATE_LIMIT_BACKENDS = [
'django_ntfy.NtfyBackend',
]

def check(sent: bool, subject_suffix: str):
if sent:
with responses.RequestsMock() as rsps:
Expand Down
43 changes: 0 additions & 43 deletions tests/test_smtp_backend.py

This file was deleted.

0 comments on commit 0ad53ad

Please sign in to comment.