-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct SMTP sending, avoid fragile doctest
- Loading branch information
Showing
7 changed files
with
40 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[pytest] | ||
testpaths = slip39 | ||
addopts = -vv --doctest-modules --ignore-glob=**/__main__.py --ignore-glob=**/main.py --ignore-glob=**/ethereum.py --cov=slip39 --cov-config=.coveragerc | ||
addopts = -v --ignore-glob=**/__main__.py --ignore-glob=**/main.py --ignore-glob=**/ethereum.py --cov=slip39 --cov-config=.coveragerc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,22 @@ | |
import os | ||
import re | ||
import sys | ||
import pytest | ||
|
||
from io import StringIO | ||
from pathlib import Path | ||
from subprocess import Popen, PIPE | ||
from email import message_from_string | ||
|
||
import dkim | ||
|
||
from aiosmtpd.controller import Controller | ||
|
||
from .communications import dkim_message, send_message, matchaddr, AutoResponder | ||
try: | ||
import dkim | ||
from .communications import dkim_message, send_message, matchaddr, AutoResponder | ||
except ImportError: | ||
dkim = None | ||
|
||
from .defaults import SMTP_TO, SMTP_FROM | ||
|
||
log = logging.getLogger( __package__ ) | ||
|
@@ -61,6 +66,8 @@ | |
""" ) | ||
|
||
|
||
@pytest.mark.skipif( not dkim, | ||
reason="DKIM support unavailable; install w/ [invoice] option" ) | ||
def test_communications_matchaddr(): | ||
assert matchaddr( "abc+def@xyz", mailbox="abc", domain="xyz" ) == ("abc", "def", "xyz") | ||
assert matchaddr( "abc+def@xyz", domain="xYz" ) == ("abc", "def", "xyz") | ||
|
@@ -73,6 +80,8 @@ def test_communications_matchaddr(): | |
assert matchaddr( "abc+def@xyz", mailbox="xxx" ) is None | ||
|
||
|
||
@pytest.mark.skipif( not dkim, | ||
reason="DKIM support unavailable; install w/ [invoice] option" ) | ||
def test_communications_dkim(): | ||
log.info( f"Using DKIM: {dkim_selector}: {dkim_key}" ) | ||
if dkim_key: | ||
|
@@ -135,6 +144,8 @@ def test_communications_dkim(): | |
pass | ||
|
||
|
||
@pytest.mark.skipif( not dkim, | ||
reason="DKIM support unavailable; install w/ [invoice] option" ) | ||
def test_communications_autoresponder( monkeypatch ): | ||
"""The Postfix-compatible auto-responder takes an email.Message from stdin, and auto-forwards it | ||
(via a relay; normally the same Postfix installation that it is running within). | ||
|
@@ -183,8 +194,8 @@ async def handle_DATA(self, server, session, envelope): | |
controller = Controller( handler, hostname='localhost', port=11111 ) | ||
controller.start() | ||
|
||
# Send the email.Message directly our SMTP daemon, w/ RCTP TO: [email protected] (taken | ||
# from the To: header) | ||
# Send the email.Message directly to our SMTP daemon, w/ RCTP TO: [email protected] | ||
# (taken from the To: header) | ||
send_message( | ||
msg, | ||
relay = controller.hostname, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters