quiltz-testsupport
A package for test support
Purpose
At QWAN we're building some applications in python. We collect usefull stuff in quiltz packages:
- quiltz-domain contains domain level modules like, entity id's, results, an email anonymizer, validators and parsers
- quiltz-testsupport (this package) contains test support modules, that supports mainly non unit tests, like integrating with smtp, probing asynchronous results and asserting log statements
- quiltz-messaging contains a messaging domain concept and an engines to send the messages. Currently only smtp sending is supported.
Modules in this package
logging
With the logging module you can assert log statements in a test using the log_collector fixture:
in test:
from quiltz.testsupport import log_collector
def test_logs_hello(log_collector):
foo()
log_collector.assert_info('hello info')
in production
def foo():
logger = logging.getLogger()
logger.info('hello info')
probing
With the probing module you can probe for async results:
from hamcrest import assert_that, equal_to
from quiltz.testsupport import probe_that
def test_stub_server_collects_message_for_recepient(self):
message = aMessage(recipient='rob@mailinator.com', sender='no-reply@qwan.eu', subject='test', body='hello test')
self.message_engine.send([message])
probe_that(lambda: self.server.messages == [stringified_message(message)])
# or
probe_that(lambda: assert_that(self.server.messages, equal_to([
stringified_message(message)
])))
# or
probe_that(lambda: self.server.messages, equal_to([
stringified_message(message)
]))
smtp
With the smtp module you can create a stub smtp server that collects smtp messages
from hamcrest import assert_that, equal_to
from quiltz.testsupport import probe_that
def server()
server = StubSmtpServer(hostname='localhost', port=9925)
server.start()
yield(server)
server.stop()
def test_collects_message_for_recepient(self, server):
message_engine = SMTPClientForTest(host='localhost', port='9925')
message = aMessage(recipient='rob@mailinator.com', sender='no-reply@qwan.eu', subject='test', body='hello test')
message_engine.send([message])
probe_that(lambda: assert_that(server.messages, equal_to([
stringified_message(message)
])))
installing
pip install quiltz-testsupport
Release files for quiltz-testsupport 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quiltz_testsupport-0.3.1.tar.gz | 10.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quiltz_testsupport-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / quiltz_testsupport-0.3.1.tar.gz
| Download URL | quiltz_testsupport-0.3.1.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4d67a664f345e3dcfacf6ea254a640e6e82992d4a42f295a46736a10a27f5f0
|
|
BLAKE2b-256 checksum How to use checksums |
3dbed3f7e06808b2a46cee2ad74ea52d14414878e3a17c36d214cfe3c7aa1651
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.15
|
Release files / quiltz_testsupport-0.3.1-py3-none-any.whl
| Download URL | quiltz_testsupport-0.3.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2162ad942e9e6bda776501c4aa81a4f3ec973de16bc445e01f3e2434455e8fbe
|
|
BLAKE2b-256 checksum How to use checksums |
ebe166a9f55fb10d22fe54ff7d9156ac5cab6c7c98a8c53493fdec1fa7aca141
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.15
|