Skip to content

Commit

Permalink
Fix places
Browse files Browse the repository at this point in the history
  • Loading branch information
amureki committed Aug 7, 2024
1 parent 87ee788 commit 3bff182
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 21 deletions.
7 changes: 3 additions & 4 deletions emark/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def send_messages(self, email_messages):


class TrackingEmailBackendMixin:
"""Add tracking framework to an email backend."""
"""Add a tracking framework to an email backend."""

def send_messages(self, email_messages):
self._messages_sent = []
Expand Down Expand Up @@ -83,7 +83,7 @@ def write_message(self, message):
msg.get_charset().get_output_charset() if msg.get_charset() else "utf-8"
)
msg_data = msg_data.decode(charset)
self.stream.write("%s\n" % msg_data)
self.stream.write(f"{msg_data}\n")
self.stream.write("-" * 79)
self.stream.write("\n")
if payload_count > 1:
Expand Down Expand Up @@ -119,8 +119,7 @@ def write_message(self, message):


class TrackingSMTPEmailBackend(TrackingEmailBackendMixin, _SMTPEmailBackend):
"""
Like the SMTP email backend but with click and open tracking.
"""Like the SMTP email backend but with click and open tracking.
Furthermore, all emails are sent to a single email address.
If multiple to, cc, or bcc addresses are specified, a separate
Expand Down
10 changes: 4 additions & 6 deletions emark/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@


class MarkdownEmail(EmailMultiAlternatives):
"""
Multipart email message that renders both plaintext and HTML from markdown.
"""Multipart email message that renders both plaintext and HTML from markdown.
This is a full class:`EmailMultiAlternatives` subclass with additional support
to send emails directly to a users. It also requires an explicit language
Expand Down Expand Up @@ -102,7 +101,7 @@ def message(self):
def get_utm_campaign_name(cls):
"""Return the UTM campaign name for this email."""
return "_".join(
(m.group(0) for m in CLS_NAME_TO_CAMPAIGN_RE.finditer(cls.__qualname__))
m.group(0) for m in CLS_NAME_TO_CAMPAIGN_RE.finditer(cls.__qualname__)
).upper()

def update_url_params(self, url, **params):
Expand Down Expand Up @@ -192,8 +191,7 @@ def get_subject(self, **context):
return self.subject % context

def get_preheader(self):
"""
Return the email's preheader.
"""Return the email's preheader.
A brief text that recipients will see in their inbox before opening the email
along with the subject. Unless explicitly set, the preheader will be the first
Expand All @@ -217,7 +215,7 @@ def get_html(self, markdown_string, context):
"markdown.extensions.extra",
],
)
context["markdown_string"] = mark_safe(html_message) # nosec
context["markdown_string"] = mark_safe(html_message) # noqa: S308

template = loader.get_template(self.base_html_template)
rendered_html = template.render(context)
Expand Down
3 changes: 1 addition & 2 deletions emark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

@dataclasses.dataclass
class Node:
"""
Simple HTML node that can be extracted into plain text.
"""Simple HTML node that can be extracted into plain text.
Nodes have a parent and children link to create a tree structure.
Plain text extraction is done by recursively traversing the tree.
Expand Down
1 change: 0 additions & 1 deletion tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest
from django.core.mail import EmailMessage, EmailMultiAlternatives

from emark import backends
from emark.models import Send

Expand Down
5 changes: 2 additions & 3 deletions tests/test_message.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import copy
from pathlib import Path

import emark.message
import pytest
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.test.html import parse_html
from model_bakery import baker

import emark.message

BASE_DIR = Path(__file__).resolve().parent.parent


Expand Down Expand Up @@ -250,7 +249,7 @@ def test_get_preheader__missing(self):
language="en-US",
context={"donut_name": "HoneyNuts", "donut_type": "Honey"},
)
msg.get_preheader() == ""
assert msg.get_preheader() == ""

def test_get_preheader(self):
email_message = MarkdownEmailTestWithPreheader(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import pytest
from django.urls import reverse
from django.utils.http import urlencode
from model_bakery import baker

from emark import models
from model_bakery import baker


class TestEmailDetailView:
Expand Down
5 changes: 2 additions & 3 deletions tests/testapp/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Django settings for testapp project.
"""Django settings for testapp project.
Generated by 'django-admin startproject' using Django 4.0.4.
Expand All @@ -20,7 +19,7 @@
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-4787+%emei)bk2ue$5^0(5_i3+fz-0^87v)myt+8y__n$-o4@l"
SECRET_KEY = "django-insecure-4787+%emei)bk2ue$5^0(5_i3+fz-0^87v)myt+8y__n$-o4@l" # noqa: S105

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down

0 comments on commit 3bff182

Please sign in to comment.