Compare commits
2 Commits
aa746b780d
...
e05f08995e
| Author | SHA1 | Date | |
|---|---|---|---|
| e05f08995e | |||
| 91d70cf10c |
@@ -46,10 +46,19 @@ jobs:
|
||||
python-version: 3.12
|
||||
|
||||
- name: Install test dependencies
|
||||
run: python -m pip install --upgrade pip && pip install -r requirements.txt
|
||||
run: python -m pip install --upgrade pip && pip install -r requirements-dev.txt
|
||||
|
||||
- name: Cache pip dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: "$RUNNER_OS-pip-${{ hashFiles('requirements-dev.txt') }}"
|
||||
restore-keys: |
|
||||
$RUNNER_OS-pip-
|
||||
|
||||
- name: Run unit tests
|
||||
run: pytest -q
|
||||
run: python -m pytest -q
|
||||
|
||||
- name: Determine registry host
|
||||
run: echo "REGISTRY=${GITHUB_SERVER_URL#*://}" >> "$GITHUB_ENV"
|
||||
|
||||
|
||||
@@ -50,11 +50,13 @@ docker run --rm -p 110:110 -p 25:25 \
|
||||
|
||||
## Tests
|
||||
|
||||
Run tests locally with:
|
||||
Install development dependencies and run the test suite:
|
||||
|
||||
```bash
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-dev.txt
|
||||
pytest -q
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -344,7 +344,7 @@ class SMTPProxyHandler:
|
||||
await asyncio.to_thread(self.send_message, envelope.mail_from, envelope.rcpt_tos, envelope.content)
|
||||
return "250 Message accepted for delivery"
|
||||
|
||||
def send_message(self, sender, recipients, data):
|
||||
def send_message(self, sender, recipients, data):
|
||||
"""Forward a complete SMTP message to the backend SMTP server."""
|
||||
message = data.decode("utf-8", errors="replace")
|
||||
if Settings.BACKEND_SMTP_USE_SSL:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[pytest]
|
||||
minversion = 7.0
|
||||
testpaths = tests
|
||||
python_files = test_*.py
|
||||
addopts = -q
|
||||
@@ -0,0 +1,2 @@
|
||||
-r requirements.txt
|
||||
pytest>=8.0.0
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
aiosmtpd>=1.6.3
|
||||
pytest>=8.0.0
|
||||
aiosmtpd>=1.4.6,<1.5
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Ensure the project root is on sys.path when running tests.
|
||||
ROOT = os.path.dirname(os.path.dirname(__file__))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
@@ -114,7 +114,7 @@ def test_smtp_proxy_handler_forwards_message_over_ssl(monkeypatch):
|
||||
assert captured["instance"].logged_in is True
|
||||
assert captured["instance"].sent[0] == "from@example.com"
|
||||
assert captured["instance"].sent[1] == ["to@example.com"]
|
||||
assert b"Subject: Test" in captured["instance"].sent[2]
|
||||
assert "Subject: Test" in captured["instance"].sent[2]
|
||||
|
||||
Settings.BACKEND_SMTP_USE_SSL = previous_ssl
|
||||
Settings.BACKEND_SMTP_USER = previous_user
|
||||
|
||||
Reference in New Issue
Block a user