mirror of
https://seed.flo-the.dev/z3gWc1qgaeZaoGwL4WTstLNoqjayM.git
synced 2025-12-06 04:47:35 +01:00
add first tests
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
46
tests/test_smtprd_ng.py
Normal file
46
tests/test_smtprd_ng.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# SMTP forwarding relay daemon with signing and encryption
|
||||
#
|
||||
# Copyright (C) 2024 F. Brandes (additions to original code)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
Tests for smtprd_ng
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
|
||||
from smtprd_ng import smtprd
|
||||
|
||||
|
||||
def test_config_from_config():
|
||||
"""Test opening and readig the config file"""
|
||||
config_parser: configparser.ConfigParser = configparser.ConfigParser()
|
||||
with open(Path("config.example"), "r", encoding="utf8") as fp:
|
||||
config_parser.read_file(fp)
|
||||
cfg = smtprd.Config._from_config(config_parser)
|
||||
assert cfg.server.hostname == "localhost"
|
||||
assert cfg.client.port == 465
|
||||
assert cfg.client.smime_cert == ""
|
||||
|
||||
|
||||
def test_config_from_ini():
|
||||
"""Test parsing the config file and using fallbacks"""
|
||||
cfg = smtprd.Config.from_ini(Path("config.example"))
|
||||
assert cfg.server.hostname == "localhost"
|
||||
assert cfg.client.port == 465
|
||||
assert cfg.client.smime_cert == ""
|
||||
assert cfg.client.use_tls is True
|
||||
Reference in New Issue
Block a user