Skip to content

Commit

Permalink
Ruff check and isort, cleanup templates and added version to the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpoi committed Jan 2, 2025
1 parent 97b8522 commit 38a24af
Show file tree
Hide file tree
Showing 33 changed files with 57 additions and 284 deletions.
2 changes: 0 additions & 2 deletions demoapp/custom_user/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.contrib import admin

# Register your models here.
1 change: 0 additions & 1 deletion demoapp/custom_user/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from django.test import TestCase

# Create your tests here.
2 changes: 0 additions & 2 deletions demoapp/custom_user/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.shortcuts import render

# Create your views here.
6 changes: 1 addition & 5 deletions demoapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
from datetime import timedelta
from pathlib import Path

from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -81,7 +80,7 @@
}
}
}
MEDIA_URL = f"http://127.0.0.1:9000/media/"
MEDIA_URL = "http://127.0.0.1:9000/media/"
else:
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'workdir' / 'media'
Expand Down Expand Up @@ -218,10 +217,7 @@
'EMAIL_TEMPLATES': [
('email/demo.html', _("Demo")),
('email/default.html', _('Default')),
('email/placeholders.html', _('Placeholders')),
('email/in.html', _('Incoming')),
('email/uni.html', _('University')),
('email/contexed_uni.html', _('Contexed')),
('email/test_updated_parser.html', 'Test updated parser'),
('email/tracker.html', _('Tracker')),
],
Expand Down
Binary file removed demoapp/static/uni/uni_logo.png
Binary file not shown.
110 changes: 0 additions & 110 deletions demoapp/templates/email/contexed_uni.html

This file was deleted.

81 changes: 0 additions & 81 deletions demoapp/templates/email/uni.html

This file was deleted.

2 changes: 1 addition & 1 deletion demoapp/tests/mailpit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):
try:
response = self.info()
self.already_running = attempts == 0
except requests.exceptions.ConnectionError as e:
except requests.exceptions.ConnectionError:
print("\nStarting Mailpit server\n")
self.process = subprocess.Popen([MAILPIT_BINARY])
sleep(0.2)
Expand Down
2 changes: 0 additions & 2 deletions demoapp/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from dataclasses import dataclass

import pytest

from sendmail.admin.admin_utils import convert_media_urls_to_tags, get_message_preview, render_placeholder_content


Expand Down
3 changes: 1 addition & 2 deletions demoapp/tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import pathlib
from datetime import timedelta
from email.mime.image import MIMEImage

import pytest
Expand Down
6 changes: 3 additions & 3 deletions demoapp/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from django.core.management import call_command
from django.utils.timezone import now

from sendmail.config import settings
from sendmail.models.attachment import Attachment
from sendmail.models.emailaddress import EmailAddress
from sendmail.models.emailmodel import STATUS, EmailModel
from sendmail.utils import set_recipients


def call_sendmail(*args, **kwargs):
return call_command('sendmail', *args, **kwargs)

Expand Down Expand Up @@ -92,7 +92,7 @@ def test_send_queued_mail():
@pytest.mark.django_db
def test_send_batch():
with mock.patch('django.db.connection.close', return_value=None):
queue = [EmailModel.objects.create(from_email='[email protected]', status=STATUS.queued, language='en') for _ in range(200)]
_ = [EmailModel.objects.create(from_email='[email protected]', status=STATUS.queued, language='en') for _ in range(200)]

call_sendmail('batch', processes=1)
assert EmailModel.objects.filter(status=STATUS.sent).count() == 100
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_failed_deliveries_logging():
"""

with mock.patch('django.db.connection.close', return_value=None):
recipient = EmailAddress.objects.create(email=f'[email protected]')
recipient = EmailAddress.objects.create(email='[email protected]')
email = EmailModel.objects.create(
from_email='[email protected]', status=STATUS.queued, backend_alias='error', language='en'
)
Expand Down
2 changes: 1 addition & 1 deletion demoapp/tests/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def test_connections():
assert isinstance(connections['slow_backend'], SlowTestBackend)

with pytest.raises(KeyError):
conn = connections['not_valid']
_ = connections['not_valid']
1 change: 0 additions & 1 deletion demoapp/tests/test_dblock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time
from datetime import timedelta
from multiprocessing import Process

import pytest

Expand Down
1 change: 0 additions & 1 deletion demoapp/tests/test_emailmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from sendmail.settings import get_template_engine
from sendmail.utils import set_recipients

#from django.conf import settings


@pytest.fixture
Expand Down
6 changes: 2 additions & 4 deletions demoapp/tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import tempfile
from multiprocessing import Pool
from typing import List

import pytest
import requests

from demoapp.tests.conftest import email_testing

from sendmail.mail import _send_bulk, send, send_many
from sendmail.models.emailaddress import EmailAddress
from sendmail.models.emailmerge import EmailMergeModel, PlaceholderContent
from sendmail.models.emailmerge import PlaceholderContent
from sendmail.utils import get_recipients_objects, split_emails


Expand Down
12 changes: 3 additions & 9 deletions demoapp/tests/test_mail.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import logging
import tempfile
from datetime import timedelta
from unittest.mock import patch
from zoneinfo import ZoneInfo

import pytest
from django.core.exceptions import ValidationError
from django.db import connection
from django.db.utils import InterfaceError
from django.test.utils import CaptureQueriesContext
from django.utils import timezone
from django.core.files.base import ContentFile

from sendmail.mail import _send_bulk, create_email, get_queued, send, send_many, split_into_batches
from sendmail.models.attachment import Attachment
from sendmail.models.emailaddress import EmailAddress, Recipient
from sendmail.models.emailmerge import EmailMergeModel, PlaceholderContent
from sendmail.models.emailmerge import EmailMergeModel
from sendmail.models.emailmodel import PRIORITY, STATUS, EmailModel
from sendmail.settings import get_available_backends

#from django.conf import settings


@pytest.fixture
Expand Down Expand Up @@ -478,7 +474,6 @@ def test_get_queued():
assert list(get_queued()) == [queued_email, past_email]


from django.core import mail


@pytest.mark.django_db
Expand Down Expand Up @@ -572,7 +567,6 @@ def test_extra_recipients(template):
assert extra[1].address.email == '[email protected]'


from django.core.files.base import ContentFile


@pytest.fixture
Expand All @@ -598,7 +592,7 @@ def template_with_extra_attachments(settings, template):
def test_extra_attachments(template_with_extra_attachments):
# Retrieve the template with the extra attachments already set up
template = template_with_extra_attachments
en_translation = template.translated_contents.get(language='en')
template.translated_contents.get(language='en')

# No need to create the attachment again since the fixture already does that
recipients = ['[email protected]', '[email protected]']
Expand Down
Loading

0 comments on commit 38a24af

Please sign in to comment.