diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0ab5259 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## v0.1.0 (2023-12-03) Initial Release + +- Initial Release of an alpha version +- Limited features +- First published version to the PyPI diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..477fcc3 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright Juergen Edelbluth and other contributors, https://juergen.rocks/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 9aade90..2d26c55 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,48 @@ # smtp-test-server -Based on the `aiosmtpd`, this packages offers you a simple way to integrate +Based on the [`aiosmtpd`](https://github.com/aio-libs/aiosmtpd), this packages offers you a simple way to integrate a SMTP server into your test code. + +Currently, the server does not support authentication, TLS or anything special instead of sending mails. + +All mails are collected in the `messages` property of the mock and can be evaluated there. + +Looking for a `pytest` SMTP mock fixture? Take a look at this project: +[git.codebau.dev/pytest-plugins/pytest-smtp-test-server](https://git.codebau.dev/pytest-plugins/pytest-smtp-test-server). + +## Installation + +### Installation with "pip" + +```Bash +pip install smtp-test-server +``` + +### Installation with "poetry" + +```Bash +poetry add --group dev smtp-test-server +``` + +## Usage + +Simple usage, with auto assigning a free port number on `127.0.0.1`: + +```Python +from smtp_test_server.context import SmtpMockServer + +def test_send_mail(): + with SmtpMockServer() as smtp_mock: + my_mail_method(smtp_host=smtp_mock.host, smtp_port=smtp_mock.port) + assert len(smtp_mock.messages) == 1 + assert smtp_mock.messages[0]["from"] == "my-test@sender.org" +``` + +Want to have more control over host and port? Use it like this: + +```Python +with SmtpMockServer(bind_host="223.12.9.177", bind_port=2525): + ... +``` + +Ports are automatically closed when leaving the context. diff --git a/poetry.lock b/poetry.lock index 8dc34de..4abfcc8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -448,13 +448,13 @@ dev = ["black", "flake8", "pre-commit"] [[package]] name = "termcolor" -version = "2.3.0" +version = "2.4.0" description = "ANSI color formatting for output in terminal" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "termcolor-2.3.0-py3-none-any.whl", hash = "sha256:3afb05607b89aed0ffe25202399ee0867ad4d3cb4180d98aaf8eefa6a5f7d475"}, - {file = "termcolor-2.3.0.tar.gz", hash = "sha256:b5b08f68937f138fe92f6c089b99f1e2da0ae56c52b78bf7075fd95420fd9a5a"}, + {file = "termcolor-2.4.0-py3-none-any.whl", hash = "sha256:9297c0df9c99445c2412e832e882a7884038a25617c60cea2ad69488d4040d63"}, + {file = "termcolor-2.4.0.tar.gz", hash = "sha256:aab9e56047c8ac41ed798fa36d892a37aca6b3e9159f3e0c24bc64a9b3ac7b7a"}, ] [package.extras]