Skip to content

Commit f7c3582

Browse files
authored
Merge pull request #186 from lavr/fix/issue-185-smtp-integration-tests
Restore SMTP integration tests using Mailpit
2 parents ecc204b + f39b0be commit f7c3582

4 files changed

Lines changed: 50 additions & 4 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
tests:
13-
name: ${{ matrix.name }}
13+
name: "unit / ${{ matrix.name }}"
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
@@ -34,10 +34,42 @@ jobs:
3434
pip install -U setuptools
3535
python -m pip install -U pip
3636
- run: pip install tox
37-
- name: run rests
37+
- name: run tests
38+
run: tox -e ${{ matrix.tox }} -- -m "not e2e"
39+
40+
e2e:
41+
name: "e2e / ${{ matrix.name }}"
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- {name: '3.14', python: '3.14', os: ubuntu-latest, tox: py314}
48+
services:
49+
mailpit:
50+
image: axllent/mailpit
51+
ports:
52+
- 1025:1025
53+
- 8025:8025
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{ matrix.python }}
59+
cache: pip
60+
- name: update pip
61+
run: |
62+
pip install -U wheel
63+
pip install -U setuptools
64+
python -m pip install -U pip
65+
- run: pip install tox
66+
- name: run e2e tests
3867
env:
3968
SMTP_TEST_SUBJECT_SUFFIX: "github-actions sha:${{ github.sha }} run_id:${{ github.run_id }}"
4069
SMTP_TEST_MAIL_FROM: python-emails-tests@lavr.me
4170
SMTP_TEST_MAIL_TO: python-emails-tests@lavr.me
42-
SMTP_TEST_SETS: ""
43-
run: tox -e ${{ matrix.tox }}
71+
SMTP_TEST_SETS: LOCAL
72+
SMTP_TEST_LOCAL_HOST: 127.0.0.1
73+
SMTP_TEST_LOCAL_PORT: 1025
74+
SMTP_TEST_LOCAL_WITHOUT_TLS: true
75+
run: tox -e ${{ matrix.tox }} -- -m e2e

emails/testsuite/message/test_send.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import unicode_literals
33
import time
44
import random
5+
import pytest
56
import emails
67
import emails.loader
78
from emails.backend.smtp import SMTPBackend
@@ -41,6 +42,16 @@ def test_send_letters():
4142
# server.sleep()
4243

4344

45+
@pytest.mark.e2e
46+
def test_send_simple():
47+
message = emails.html(**common_email_data(subject='Simple e2e test'))
48+
for tag, server in get_servers():
49+
server.patch_message(message)
50+
response = message.send(smtp=server.params)
51+
assert response.success
52+
53+
54+
@pytest.mark.e2e
4455
def test_send_with_context_manager():
4556
for _, server in get_servers():
4657
b = SMTPBackend(**server.params)

emails/testsuite/smtp/test_smtp_backend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_send_to_unknown_host():
2626
assert response.error.errno == socket.EAI_NONAME
2727

2828

29+
@pytest.mark.e2e
2930
def test_smtp_send_with_reconnect():
3031
"""
3132
Check SMTPBackend.sendmail reconnect

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ universal=1
33

44
[tool:pytest]
55
norecursedirs = .* {arch} *.egg *.egg-info dist build requirements
6+
markers =
7+
e2e: tests that require a running SMTP server

0 commit comments

Comments
 (0)