From 1742ee07c8bb72d420bc6ccb888e1a8c15c1312a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 14 Oct 2023 12:01:39 +0200 Subject: [PATCH] add smtp tests and fix scripts --- online-tests/conftest.py | 19 +++++++++++++++++++ scripts/init.sh | 2 +- scripts/test.sh | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/online-tests/conftest.py b/online-tests/conftest.py index 319bea38..f98a0891 100644 --- a/online-tests/conftest.py +++ b/online-tests/conftest.py @@ -1,4 +1,5 @@ import imaplib +import smtplib import itertools import pytest @@ -21,6 +22,24 @@ class ImapConn: self.conn.login(user, password) +@pytest.fixture +def smtp(): + return SmtpConn("c1.testrun.org") + + +class SmtpConn: + def __init__(self, host): + self.host = host + + def connect(self): + print(f"smtp-connect {self.host}") + self.conn = smtplib.SMTP_SSL(self.host) + + def login(self, user, password): + print(f"smtp-login {user!r} {password!r}") + self.conn.login(user, password) + + @pytest.fixture def gencreds(): count = itertools.count() diff --git a/scripts/init.sh b/scripts/init.sh index 4f7dc33c..889f8ba0 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -9,4 +9,4 @@ doveauth/venv/bin/pip install pytest build doveauth/venv/bin/pip install -e doveauth python3 -m venv online-tests/venv -online-tests/venv/bin/pip install pytest pytest-timeout +online-tests/venv/bin/pip install pytest pytest-timeout pdbpp diff --git a/scripts/test.sh b/scripts/test.sh index 4e5ab986..0bca51c8 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -2,4 +2,5 @@ pushd doveauth/src/doveauth ../../venv/bin/pytest popd -online-tests/venv/bin/pytest online-tests/ + +online-tests/venv/bin/pytest online-tests/ -vrx